From b58c4ac9cc9eaf0fa9f511e61ee77dcfa40db8c0 Mon Sep 17 00:00:00 2001 From: msekar Date: Wed, 20 Jan 2016 23:24:26 +0100 Subject: [PATCH] SQL file --- tables.sql | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+), 0 deletions(-) create mode 100644 tables.sql diff --git a/tables.sql b/tables.sql new file mode 100644 index 0000000..02330f1 --- /dev/null +++ b/tables.sql @@ -0,0 +1,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) +); \ No newline at end of file -- libgit2 0.21.2