put complete sql setup in one file

This commit is contained in:
Marcel Schwarz 2020-03-14 03:05:28 +01:00
parent 2d00d0e068
commit eb7c6eeabe
3 changed files with 25 additions and 14 deletions

View File

@ -1 +0,0 @@
CREATE TABLE `friendsbook`.`tans` ( `id` INT NOT NULL AUTO_INCREMENT , `tan` VARCHAR(13) NOT NULL , `used` BOOLEAN NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;

View File

@ -1,4 +1,24 @@
CREATE TABLE `kd42696_ipr-projekt`.`entries` ( CREATE DATABASE friendsbook;
USE friendsbook;
CREATE TABLE `tans` (
`id` INT NOT NULL AUTO_INCREMENT,
`tan` VARCHAR(13) NOT NULL,
`used` BOOLEAN NOT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;
CREATE TABLE `user` (
`ID` INT NOT NULL AUTO_INCREMENT,
`user` VARCHAR(50) NOT NULL DEFAULT '0',
`email` VARCHAR(100) NOT NULL DEFAULT '0',
`password` VARCHAR(100) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
UNIQUE INDEX `user` (`user`)
) ENGINE = InnoDB;
CREATE TABLE `entries` (
`id` INT NOT NULL AUTO_INCREMENT , `id` INT NOT NULL AUTO_INCREMENT ,
`userID` INT NOT NULL , `userID` INT NOT NULL ,
`tanID` INT NOT NULL , `tanID` INT NOT NULL ,
@ -26,7 +46,7 @@ CREATE TABLE `kd42696_ipr-projekt`.`entries` (
`absturz` LONGTEXT DEFAULT NULL , `absturz` LONGTEXT DEFAULT NULL ,
`trinkspiel` LONGTEXT DEFAULT NULL , `trinkspiel` LONGTEXT DEFAULT NULL ,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE (`tanID`)) ENGINE = InnoDB; UNIQUE (`tanID`),
FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
ALTER TABLE `entries` ADD FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE; FOREIGN KEY (`tanID`) REFERENCES `tans`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE `entries` ADD FOREIGN KEY (`tanID`) REFERENCES `tans`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; ) ENGINE = InnoDB;

View File

@ -1,8 +0,0 @@
CREATE TABLE `user` (
`ID` INT NOT NULL AUTO_INCREMENT,
`user` VARCHAR(50) NOT NULL DEFAULT '0',
`email` VARCHAR(100) NOT NULL DEFAULT '0',
`password` VARCHAR(100) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
UNIQUE INDEX `user` (`user`)
);