]>
Git — Sourcephile - tmp/julm/LesQuatreRoux.git/blob - sql/init/Ingrédient.sql
1 \p
CREATE TABLE Ingrédient
2 CREATE CACHED
TABLE "Ingrédient"
3 ( ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL
4 , produit
INTEGER NOT NULL
5 , conso
INTEGER NOT NULL
6 , quantité
DECIMAL(100,3) DEFAULT 1.000 NOT NULL
7 , CONSTRAINT "PK_Ingrédient" PRIMARY KEY(ID)
9 CREATE UNIQUE INDEX "Ingrédient_index_produit_et_conso"
10 ON "Ingrédient"(produit
,conso
);
11 ALTER TABLE "Ingrédient"
12 ADD CONSTRAINT "Un produit ne se liste pas lui-même comme consommation"
13 CHECK (produit
!= conso
)
14 ALTER TABLE "Ingrédient" ADD CONSTRAINT "FK_Ingrédient_produit" FOREIGN KEY(produit
) REFERENCES "Produit"(ID)
16 ALTER TABLE "Ingrédient" ADD CONSTRAINT "FK_Ingrédient_conso" FOREIGN KEY(conso
) REFERENCES "Produit"(ID)