diff --git a/officeHoursMysql.sql b/officeHoursMysql.sql index 969add5..fd8ef8c 100644 --- a/officeHoursMysql.sql +++ b/officeHoursMysql.sql @@ -1,8 +1,13 @@ +DROP TABLE IF EXISTS `request`; +DROP TABLE IF EXISTS `officeHour`; +DROP TABLE IF EXISTS `room`; +DROP TABLE IF EXISTS `tutor`; +DROP TABLE IF EXISTS `course`; + -- -- Table structure for table `room` -- -DROP TABLE IF EXISTS `room`; CREATE TABLE `room` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `name` text NOT NULL, @@ -10,22 +15,28 @@ CREATE TABLE `room` ( ); -- --- Table structure for table `request` +-- Table structure for table `tutor` -- -DROP TABLE IF EXISTS `request`; -CREATE TABLE `request` ( +CREATE TABLE `tutor` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, - `officeHour` int DEFAULT NULL, - `action` int DEFAULT NULL, - `secret` text DEFAULT NULL + `name` tinytext DEFAULT NULL, + `email` tinytext DEFAULT NULL +); + +-- +-- Table structure for table `course` +-- + +CREATE TABLE `course` ( + `id` INTEGER PRIMARY KEY AUTO_INCREMENT, + `name` varchar(255) DEFAULT NULL ); -- -- Table structure for table `officeHour` -- -DROP TABLE IF EXISTS `officeHour`; CREATE TABLE `officeHour` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `tutor` int DEFAULT NULL, @@ -38,26 +49,20 @@ CREATE TABLE `officeHour` ( `week` int DEFAULT NULL, `info` text DEFAULT NULL, `active` bool DEFAULT NULL, - `duration` int DEFAULT NULL + `duration` int DEFAULT NULL, + FOREIGN KEY (tutor) REFERENCES tutor(id), + FOREIGN KEY (room) REFERENCES room(id), + FOREIGN KEY (course) REFERENCES course(id) ); -- --- Table structure for table `tutor` +-- Table structure for table `request` -- -DROP TABLE IF EXISTS `tutor`; -CREATE TABLE `tutor` ( +CREATE TABLE `request` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, - `name` tinytext DEFAULT NULL, - `email` tinytext DEFAULT NULL -); - --- --- Table structure for table `course` --- - -DROP TABLE IF EXISTS `course`; -CREATE TABLE `course` ( - `id` INTEGER PRIMARY KEY AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL + `officeHour` int DEFAULT NULL, + `action` int DEFAULT NULL, + `secret` tinytext DEFAULT NULL, + FOREIGN KEY (officeHour) REFERENCES officeHour(id) ); diff --git a/officeHoursSQLite.sql b/officeHoursSQLite.sql index ef71d6b..70f7109 100644 --- a/officeHoursSQLite.sql +++ b/officeHoursSQLite.sql @@ -18,7 +18,8 @@ CREATE TABLE `request` ( `id` INTEGER PRIMARY KEY, `officeHour` int DEFAULT NULL, `action` int DEFAULT NULL, - `secret` text DEFAULT NULL + `secret` text DEFAULT NULL, + FOREIGN KEY (officeHour) REFERENCES officeHour(id) ); -- @@ -38,7 +39,10 @@ CREATE TABLE `officeHour` ( `week` int DEFAULT NULL, `info` text DEFAULT NULL, `active` bool DEFAULT NULL, - `duration` int DEFAULT NULL + `duration` int DEFAULT NULL, + FOREIGN KEY (tutor) REFERENCES tutor(id), + FOREIGN KEY (room) REFERENCES room(id), + FOREIGN KEY (course) REFERENCES course(id) ); --