DirektiveDesDons/BancaDati.sql

69 lines
3.0 KiB
MySQL
Raw Normal View History

2023-01-11 10:33:20 +01:00
SET
SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET
time_zone = "+00:00";
CREATE TABLE `ingredienti`
( /*Zutaten*/
2023-01-12 14:49:58 +01:00
`id` int auto_increment NOT NULL PRIMARY KEY,
2023-01-11 10:33:20 +01:00
`cognome` varchar(200) NOT NULL, /*Name*/
`caloriePerCento` integer(5) NOT NULL, /*Kalorien pro Gramm*/
`ilPeso` integer(5) NULL, /*Gewicht*/
2023-01-11 10:33:20 +01:00
`prezzo` decimal(4, 2) NOT NULL, /*Preis*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
2022-12-15 14:47:47 +01:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2023-01-11 10:33:20 +01:00
CREATE TABLE `folla`
( /*Menge*/
2023-01-12 14:49:58 +01:00
`id` int auto_increment NOT NULL PRIMARY KEY,
2023-01-11 10:33:20 +01:00
`unita` varchar(200) NOT NULL, /*Einheit*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
2022-12-15 15:11:16 +01:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2023-01-11 10:33:20 +01:00
CREATE TABLE `elenco`
( /*Liste*/
2023-01-12 14:49:58 +01:00
`id` int auto_increment NOT NULL PRIMARY KEY,
2023-01-11 10:33:20 +01:00
`creatore` varchar(200) NOT NULL, /*Ersteller*/
`coloreDiSfondo` integer(10) NOT NULL, /*Hintergrundfarbe*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
2022-12-15 15:11:16 +01:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2023-01-11 10:33:20 +01:00
CREATE TABLE `utente`
( /*Benutzer*/
2023-01-12 14:49:58 +01:00
`id` int auto_increment NOT NULL PRIMARY KEY,
2023-01-12 14:46:46 +01:00
`email` varchar(200) NOT NULL, /*Email*/
`parolaDordine` varchar(255) NOT NULL, /*Passwort*/
`nomeUtente` varchar(50) UNIQUE NOT NULL, /*Benutzernamen*/
2023-01-11 10:45:08 +01:00
`gettone` varchar(255), /*Token für Session*/
2023-01-12 14:46:46 +01:00
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
2022-12-15 15:11:16 +01:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2023-01-11 10:33:20 +01:00
CREATE TABLE `elencoIngredienti`
( /*Liste_Zutaten*/
2023-01-12 14:49:58 +01:00
`id` int auto_increment NOT NULL PRIMARY KEY,
2023-01-11 10:33:20 +01:00
`ingredientiID` varchar(36) NOT NULL, /*ZutatenID*/
`elencoID` varchar(36) NOT NULL, /*ListeID*/
`follaID` varchar(36) NOT NULL, /*MengeID*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
2022-12-15 15:11:16 +01:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2023-01-11 10:33:20 +01:00
CREATE TABLE `utenteElenco`
( /*Benutzer_Liste*/
2023-01-12 14:49:58 +01:00
`id` int auto_increment NOT NULL PRIMARY KEY,
2023-01-11 10:33:20 +01:00
`elencoID` varchar(36) NOT NULL, /*ListeID*/
`utenteID` varchar(36) NOT NULL, /*BenutzerID*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
2022-12-15 15:11:16 +01:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2023-01-11 14:36:18 +01:00
ALTER TABLE `elencoIngredienti` /*Liste_Zutaten*/
2022-12-15 15:11:16 +01:00
ADD PRIMARY KEY (`id`),
ADD CONSTRAINT `FK_ElencoIngredienti_Ingredienti` FOREIGN KEY (`ingredientiID`) REFERENCES `ingredienti`(`id`), /*Liste_Zutaten hat Foreignkey von Zutaten(id)*/
2022-12-21 10:25:57 +01:00
ADD CONSTRAINT `FK_ElencoIngredienti_Elenco` FOREIGN KEY (`elencoID`) REFERENCES `elenco`(`id`), /*Liste_Zutaten hat Foreignkey von Liste(id)*/
2022-12-15 15:11:16 +01:00
ADD CONSTRAINT `FK_ElencoIngredienti_Folla` FOREIGN KEY (`follaID`) REFERENCES `folla`(`id`); /*Liste_Zutaten hat Foreignkey von Menge(id)*/
2023-01-11 14:36:18 +01:00
ALTER TABLE `utenteElenco` /*Benutzer_Liste*/
2022-12-15 15:11:16 +01:00
ADD PRIMARY KEY (`id`),
ADD CONSTRAINT `FK_UtenteElenco_Utente` FOREIGN KEY (`utenteId`) REFERENCES `utente`(`id`), /*Benutzer_Liste hat Foreignkey von Benutzer(id)*/
2022-12-21 10:27:40 +01:00
ADD CONSTRAINT `FK_UtenteElenco_Elenco` FOREIGN KEY (`elencoId`) REFERENCES `elenco`(`id`); /*Benutzer_Liste hat Foreignkey von Liste(id)*/