From cb83ab2c7117c7fb9003baacb8816dccd3f86662 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 15 Dec 2022 15:11:16 +0100 Subject: [PATCH] Datenbank Datei --- BancaDati.sql | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/BancaDati.sql b/BancaDati.sql index daa96c2..7d2c36a 100644 --- a/BancaDati.sql +++ b/BancaDati.sql @@ -25,5 +25,61 @@ CREATE TABLE `ingredienti` ( /*Zutaten*/ `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `folla` ( /*Menge*/ +`id` varchar(36) NOT NULL, +`unita` varchar(200) NOT NULL, /*Einheit*/ +`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `elenco` ( /*Liste*/ +`id` varchar(36) NOT NULL, +`creatore` varchar(200) NOT NULL, /*Ersteller*/ +`coloreDiSfondo` integer(10) NOT NULL, /*Hintergrundfarbe*/ +`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `utente` ( /*Benutzer*/ +`id` varchar(36) NOT NULL, +`email` varchar(200) NOT NULL, /*Email*/ +`parolaDordine` integer(10) NOT NULL, /*Passwort*/ +`nomeUtente` integer(10) NOT NULL, /*Benutzernamen*/ +`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `elencoIngredienti` ( /*Liste_Zutaten*/ +`id` varchar(36) NOT NULL, +`ingredientiID` varchar(36) NOT NULL, /*ZutatenID*/ +`elencoID` varchar(36) NOT NULL, /*ListeID*/ +`follaID` integer(10) NOT NULL, /*MengeID*/ +`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `utenteElenco` ( /*Benutzer_Liste*/ +`id` varchar(36) NOT NULL, +`elencoID` varchar(36) NOT NULL, /*ListeID*/ +`utenteID` varchar(36) NOT NULL, /*BenutzerID*/ +`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + ALTER TABLE `ingredienti` - ADD PRIMARY KEY (`id`) + ADD PRIMARY KEY (`id`); + +ALTER TABLE `folla` + ADD PRIMARY KEY (`id`); + +ALTER TABLE `elenco` + ADD PRIMARY KEY (`id`); + +ALTER TABLE `utente` + ADD PRIMARY KEY (`id`); + +ALTER TABLE `elencoIngredienti` + ADD PRIMARY KEY (`id`), + ADD CONSTRAINT `FK_ElencoIngredienti_Ingredienti` FOREIGN KEY (`ingredientiID`) REFERENCES `ingredienti`(`id`), /*Liste_Zutaten hat Foreignkey von Zutaten(id)*/ + ADD CONSTRAINT `FK_ElencoIngredienti_Elenco` FOREIGN KEY (`elencoID`) REFERENCES `elenco`(`id`); /*Liste_Zutaten hat Foreignkey von Liste(id)*/ + ADD CONSTRAINT `FK_ElencoIngredienti_Folla` FOREIGN KEY (`follaID`) REFERENCES `folla`(`id`); /*Liste_Zutaten hat Foreignkey von Menge(id)*/ + +ALTER TABLE `utenteElenco` + ADD PRIMARY KEY (`id`), + ADD CONSTRAINT `FK_UtenteElenco_Utente` FOREIGN KEY (`utenteId`) REFERENCES `utente`(`id`), /*Benutzer_Liste hat Foreignkey von Benutzer(id)*/ + ADD CONSTRAINT `FK_UtenteElenco_Elenco` FOREIGN KEY (`elencoId`) REFERENCES `elenco`(`id`), /*Benutzer_Liste hat Foreignkey von Liste(id)*/