internetprogrammierung/sql/setup-database.sql

55 lines
1.7 KiB
MySQL
Raw Normal View History

2020-03-14 03:05:28 +01:00
CREATE DATABASE friendsbook;
USE friendsbook;
CREATE TABLE `user` (
`ID` INT NOT NULL AUTO_INCREMENT,
2020-03-14 19:50:49 +01:00
`username` VARCHAR(50) NOT NULL DEFAULT '0',
2020-03-14 03:05:28 +01:00
`email` VARCHAR(100) NOT NULL DEFAULT '0',
`password` VARCHAR(100) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
2020-03-14 19:50:49 +01:00
UNIQUE INDEX `user`(`username`)
) ENGINE = InnoDB;
CREATE TABLE `tans` (
`id` INT NOT NULL AUTO_INCREMENT,
`userID` INT NOT NULL,
`tan` VARCHAR(13) NOT NULL,
`used` BOOLEAN NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE
2020-03-14 03:05:28 +01:00
) ENGINE = InnoDB;
CREATE TABLE `entries` (
`id` INT NOT NULL AUTO_INCREMENT ,
`userID` INT NOT NULL ,
`tanID` INT NOT NULL ,
`vorname` LONGTEXT NOT NULL ,
`nachname` LONGTEXT NOT NULL ,
2018-06-17 22:23:11 +02:00
`geburtstag` LONGTEXT DEFAULT NULL ,
`wohnort` LONGTEXT DEFAULT NULL ,
`strasse` LONGTEXT DEFAULT NULL ,
`kennenUns` LONGTEXT NOT NULL ,
2018-06-17 22:23:11 +02:00
`festnetz` LONGTEXT DEFAULT NULL ,
`handynummer` LONGTEXT DEFAULT NULL ,
`email` LONGTEXT NOT NULL ,
2018-06-17 22:23:11 +02:00
`hobbies` LONGTEXT DEFAULT NULL ,
`berufswunsch` LONGTEXT DEFAULT NULL ,
`essen` LONGTEXT DEFAULT NULL ,
`insel` LONGTEXT DEFAULT NULL ,
`film` LONGTEXT DEFAULT NULL ,
`sport` LONGTEXT DEFAULT NULL ,
`charakter` LONGTEXT DEFAULT NULL ,
`tier` LONGTEXT DEFAULT NULL ,
`musik` LONGTEXT DEFAULT NULL ,
`game` LONGTEXT DEFAULT NULL ,
`alk` LONGTEXT DEFAULT NULL ,
`story` LONGTEXT DEFAULT NULL ,
`absturz` LONGTEXT DEFAULT NULL ,
`trinkspiel` LONGTEXT DEFAULT NULL ,
PRIMARY KEY (`id`),
2020-03-14 03:05:28 +01:00
UNIQUE (`tanID`),
FOREIGN KEY (`userID`) REFERENCES `user`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`tanID`) REFERENCES `tans`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB;