Blame view

tables.sql 672 Bytes
b58c4ac9   msekar   SQL file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  CREATE DATABASE `IOT`;
  
  USE `IoT`;
  
  CREATE TABLE IF NOT EXISTS `user` (
          `id` int(8) NOT NULL AUTO_INCREMENT,
          `name` varchar(32) NOT NULL,
          PRIMARY KEY (id)
  );
  
  
  CREATE TABLE IF NOT EXISTS `training` (
          `trainingId` int(8) NOT NULL,
          `trainingDate` DATE NOT NULL,
          `userId` int(8) NOT NULL,
          PRIMARY KEY (trainingId),
          FOREIGN KEY (userId) REFERENCES user(id)
  );
  
  
  CREATE TABLE IF NOT EXISTS `lap` (
          `lapId` int(8) NOT NULL ,
          `lapTime` int(8) NOT NULL,
          `trainingId` int(8) NOT NULL,
          PRIMARY KEY (lapId, trainingId),
          FOREIGN KEY (trainingId) REFERENCES training(trainingId)
  );