tables.sql 672 Bytes
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)
);