1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
-------------------------------------------
-- Base de données Produits (SQL Server) --
-------------------------------------------
CREATE TABLE Site (
Id_Site INTEGER NOT NULL,
Nom_Site CHAR(48) NOT NULL,
User_Site CHAR(16) NOT NULL,
PRIMARY KEY(Id_Site),
UNIQUE(User_Site)
);
CREATE TABLE Utilisateur (
Id_User INTEGER NOT NULL,
Id_Site INTEGER NOT NULL,
Nom_User CHAR(48) NOT NULL,
PRIMARY KEY(Id_User),
FOREIGN KEY(Id_Site)
REFERENCES Site(Id_Site)
ON DELETE NO ACTION
);
CREATE TABLE Produit (
Id_Produit INTEGER NOT NULL,
Nom_Produit CHAR(48) NOT NULL,
User_Produit CHAR(16) NOT NULL,
PRIMARY KEY(Id_Produit),
UNIQUE(User_Produit)
);
CREATE TABLE Sous_Produit (
Id_Produit INTEGER NOT NULL,
Id_Site INTEGER NOT NULL,
Id_Sous_Produit INTEGER NOT NULL,
Nom_Sous_Produit CHAR(48) NOT NULL,
User_Sous_Produit CHAR(16) NOT NULL,
PRIMARY KEY(Id_Produit, Id_Site, Id_Sous_Produit),
UNIQUE(User_Sous_Produit, Id_Site),
FOREIGN KEY(Id_Produit)
REFERENCES Produit(Id_Produit)
ON DELETE CASCADE
ON UPDATE NO ACTION,
FOREIGN KEY(Id_Site)
REFERENCES Site(Id_Site)
ON DELETE NO ACTION
);
CREATE TABLE Sous_Sous_Produit (
Id_Produit INTEGER NOT NULL,
Id_Site INTEGER NOT NULL,
Id_Sous_Produit INTEGER NOT NULL,
Id_Sous_Sous_Produit INTEGER NOT NULL,
Nom_Sous_Sous_Produit CHAR(48) NOT NULL,
User_Sous_Sous_Produit CHAR(16) NOT NULL,
PRIMARY KEY(Id_Produit, Id_Site, Id_Sous_Produit, Id_Sous_Sous_Produit),
UNIQUE(User_Sous_Sous_Produit, Id_Site),
FOREIGN KEY(Id_Produit, Id_Site, Id_Sous_Produit)
REFERENCES Sous_Produit(Id_Produit, Id_Site, Id_Sous_Produit)
ON DELETE CASCADE
); |