Added ON UPDATE ON DELETE
This commit is contained in:
parent
4000eddd4c
commit
cb83566a2e
@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS Naehrwerte
|
|||||||
Kohlenhydrate double,
|
Kohlenhydrate double,
|
||||||
Fett double,
|
Fett double,
|
||||||
Brennwert double,
|
Brennwert double,
|
||||||
foreign key (ProduktID) references Produkt (ProduktID),
|
foreign key (ProduktID) references Produkt (ProduktID) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
primary key (ProduktID, Menge, Einheit)
|
primary key (ProduktID, Menge, Einheit)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS Menge
|
|||||||
Menge int,
|
Menge int,
|
||||||
Einheit varchar(100),
|
Einheit varchar(100),
|
||||||
primary key (MengenID),
|
primary key (MengenID),
|
||||||
foreign key (ProduktID) references Produkt (ProduktID)
|
foreign key (ProduktID) references Produkt (ProduktID) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS Person
|
CREATE TABLE IF NOT EXISTS Person
|
||||||
@ -73,8 +73,8 @@ CREATE TABLE IF NOT EXISTS Menucontent
|
|||||||
(
|
(
|
||||||
MenuID int,
|
MenuID int,
|
||||||
MengenID int,
|
MengenID int,
|
||||||
foreign key (MenuID) references Menu (MenuID),
|
foreign key (MenuID) references Menu (MenuID) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
foreign key (MengenID) references Menge (MengenID),
|
foreign key (MengenID) references Menge (MengenID) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
primary key (MenuID, MengenID)
|
primary key (MenuID, MengenID)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -82,8 +82,8 @@ CREATE TABLE IF NOT EXISTS Allergie
|
|||||||
(
|
(
|
||||||
PersonID int,
|
PersonID int,
|
||||||
AllergenID int,
|
AllergenID int,
|
||||||
foreign key (PersonID) references Person (PersonID),
|
foreign key (PersonID) references Person (PersonID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
foreign key (AllergenID) references Allergen (AllergenID),
|
foreign key (AllergenID) references Allergen (AllergenID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
primary key (PersonID, AllergenID)
|
primary key (PersonID, AllergenID)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -92,8 +92,8 @@ CREATE TABLE IF NOT EXISTS enthaeltZusatzstoff
|
|||||||
ProduktID int,
|
ProduktID int,
|
||||||
E_Nummer varchar(5),
|
E_Nummer varchar(5),
|
||||||
Anwendungsgrund varchar(5),
|
Anwendungsgrund varchar(5),
|
||||||
foreign key (ProduktID) references Produkt (ProduktID),
|
foreign key (ProduktID) references Produkt (ProduktID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
foreign key (E_Nummer) references Zusatzstoff (E_Nummer),
|
foreign key (E_Nummer) references Zusatzstoff (E_Nummer) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
primary key (ProduktID, E_Nummer)
|
primary key (ProduktID, E_Nummer)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -101,8 +101,8 @@ CREATE TABLE IF NOT EXISTS Zusatzstoffunvertraeglichkeit
|
|||||||
(
|
(
|
||||||
PersonID int,
|
PersonID int,
|
||||||
E_Nummer varchar(5),
|
E_Nummer varchar(5),
|
||||||
foreign key (PersonID) references Person (PersonID),
|
foreign key (PersonID) references Person (PersonID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
foreign key (E_Nummer) references Zusatzstoff (E_Nummer),
|
foreign key (E_Nummer) references Zusatzstoff (E_Nummer) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
primary key (PersonID, E_Nummer)
|
primary key (PersonID, E_Nummer)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -110,8 +110,8 @@ CREATE TABLE IF NOT EXISTS enthaeltAllergen
|
|||||||
(
|
(
|
||||||
AllergenID int,
|
AllergenID int,
|
||||||
ProduktID int,
|
ProduktID int,
|
||||||
foreign key (AllergenID) references Allergen (AllergenID),
|
foreign key (AllergenID) references Allergen (AllergenID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
foreign key (ProduktID) references Produkt (ProduktID),
|
foreign key (ProduktID) references Produkt (ProduktID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
primary key (AllergenID, ProduktID)
|
primary key (AllergenID, ProduktID)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ CREATE TABLE IF NOT EXISTS konsumiert
|
|||||||
PersonID int,
|
PersonID int,
|
||||||
MenuID int,
|
MenuID int,
|
||||||
Datum datetime,
|
Datum datetime,
|
||||||
foreign key (PersonID) references Person (PersonID),
|
foreign key (PersonID) references Person (PersonID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
foreign key (MenuID) references Menu (MenuID),
|
foreign key (MenuID) references Menu (MenuID) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
primary key (TransaktionsID)
|
primary key (TransaktionsID)
|
||||||
)
|
)
|
Loading…
Reference in New Issue
Block a user