Inserted suitable foreign keys in a sqlite compatible way
This commit is contained in:
parent
c54ecdab71
commit
be904a7ab3
1 changed files with 16 additions and 18 deletions
|
@ -14,8 +14,8 @@ CREATE TABLE IF NOT EXISTS Recipes (
|
||||||
RecipeYear Year,
|
RecipeYear Year,
|
||||||
ingrediences int,
|
ingrediences int,
|
||||||
ProductID int,
|
ProductID int,
|
||||||
PRIMARY KEY (RecipeName, RecipeYear)
|
PRIMARY KEY (RecipeName, RecipeYear),
|
||||||
FOREIGN KEY (ingrediences) REFERENCES ingredience(IngredienceID)
|
FOREIGN KEY (ingrediences) REFERENCES ingredience(IngredienceID),
|
||||||
FOREIGN KEY (ProductID) REFERENCES Products(ProductID)
|
FOREIGN KEY (ProductID) REFERENCES Products(ProductID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -36,13 +36,16 @@ CREATE TABLE IF NOT EXISTS RawMaterials (
|
||||||
CREATE TABLE IF NOT EXISTS PalletsProduced (
|
CREATE TABLE IF NOT EXISTS PalletsProduced (
|
||||||
PalletID int PRIMARY KEY,
|
PalletID int PRIMARY KEY,
|
||||||
ProductID int,
|
ProductID int,
|
||||||
ProductionDateTime datetime
|
ProductionDateTime datetime,
|
||||||
|
FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS PalletsDelivered (
|
CREATE TABLE IF NOT EXISTS PalletsDelivered (
|
||||||
DeliveredID int PRIMARY KEY,
|
DeliveredID int PRIMARY KEY,
|
||||||
PalletID int,
|
PalletID int,
|
||||||
DeliveryDateTime datetime
|
DeliveryDateTime datetime,
|
||||||
|
FOREIGN KEY (PalletID) REFERENCES PalletsProduced (PalletID),
|
||||||
|
FOREIGN KEY (DeliveredID) REFERENCES Truck (Pallet)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS Truck (
|
CREATE TABLE IF NOT EXISTS Truck (
|
||||||
|
@ -55,7 +58,8 @@ CREATE TABLE IF NOT EXISTS loadingBill (
|
||||||
LoadingbillID int PRIMARY KEY,
|
LoadingbillID int PRIMARY KEY,
|
||||||
adress varchar(100),
|
adress varchar(100),
|
||||||
customer varchar(100),
|
customer varchar(100),
|
||||||
truckID int
|
truckID int,
|
||||||
|
FOREIGN KEY (truckID) REFERENCES Truck (truckId)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS Orders (
|
CREATE TABLE IF NOT EXISTS Orders (
|
||||||
|
@ -63,28 +67,22 @@ CREATE TABLE IF NOT EXISTS Orders (
|
||||||
CustomerID int,
|
CustomerID int,
|
||||||
ProductID int,
|
ProductID int,
|
||||||
Quantity int,
|
Quantity int,
|
||||||
OrderDateTime datetime
|
OrderDateTime datetime,
|
||||||
|
FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),
|
||||||
|
FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS BlockedProducts (
|
CREATE TABLE IF NOT EXISTS BlockedProducts (
|
||||||
BlockedProductID int PRIMARY KEY,
|
BlockedProductID int PRIMARY KEY,
|
||||||
ProductID int,
|
ProductID int,
|
||||||
BlockedDateTime datetime
|
BlockedDateTime datetime,
|
||||||
|
FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS PalletTraceability (
|
CREATE TABLE IF NOT EXISTS PalletTraceability (
|
||||||
TraceID int PRIMARY KEY,
|
TraceID int PRIMARY KEY,
|
||||||
location varchar(100),
|
location varchar(100),
|
||||||
locationdate datetime,
|
locationdate datetime,
|
||||||
PalletID int
|
PalletID int,
|
||||||
|
FOREIGN KEY (PalletID) REFERENCES PalletsProduced (PalletID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
-- ALTER TABLE PalletsProduced ADD FOREIGN KEY (ProductID) REFERENCES Products (ProductID);
|
|
||||||
-- ALTER TABLE PalletsDelivered ADD FOREIGN KEY (PalletID) REFERENCES PalletsProduced (PalletID);
|
|
||||||
-- ALTER TABLE PalletsDelivered ADD FOREIGN KEY (DeliveredID) REFERENCES Truck (Pallet);
|
|
||||||
-- ALTER TABLE loadingBill ADD FOREIGN KEY (truckID) REFERENCES Truck (truckId);
|
|
||||||
-- ALTER TABLE Orders ADD FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID);
|
|
||||||
-- ALTER TABLE Orders ADD FOREIGN KEY (ProductID) REFERENCES Products (ProductID);
|
|
||||||
-- ALTER TABLE BlockedProducts ADD FOREIGN KEY (ProductID) REFERENCES Products (ProductID);
|
|
||||||
-- ALTER TABLE PalletTraceability ADD FOREIGN KEY (PalletID) REFERENCES PalletsProduced (PalletID);
|
|
||||||
|
|
Loading…
Reference in a new issue