Commit b58c4ac9cc9eaf0fa9f511e61ee77dcfa40db8c0

Authored by msekar
1 parent d98ad89a

SQL file

Showing 1 changed file with 27 additions and 0 deletions   Show diff stats
tables.sql 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +CREATE DATABASE `IOT`;
  2 +
  3 +USE `IoT`;
  4 +
  5 +CREATE TABLE IF NOT EXISTS `user` (
  6 + `id` int(8) NOT NULL AUTO_INCREMENT,
  7 + `name` varchar(32) NOT NULL,
  8 + PRIMARY KEY (id)
  9 +);
  10 +
  11 +
  12 +CREATE TABLE IF NOT EXISTS `training` (
  13 + `trainingId` int(8) NOT NULL,
  14 + `trainingDate` DATE NOT NULL,
  15 + `userId` int(8) NOT NULL,
  16 + PRIMARY KEY (trainingId),
  17 + FOREIGN KEY (userId) REFERENCES user(id)
  18 +);
  19 +
  20 +
  21 +CREATE TABLE IF NOT EXISTS `lap` (
  22 + `lapId` int(8) NOT NULL ,
  23 + `lapTime` int(8) NOT NULL,
  24 + `trainingId` int(8) NOT NULL,
  25 + PRIMARY KEY (lapId, trainingId),
  26 + FOREIGN KEY (trainingId) REFERENCES training(trainingId)
  27 +);
0 \ No newline at end of file 28 \ No newline at end of file