]> Git — Sourcephile - tmp/julm/LesQuatreRoux.git/blob - sql/init/Ingrédient.sql
dev sql
[tmp/julm/LesQuatreRoux.git] / 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)
8 , CONSTRAINT "Un produit ne se liste pas lui-même comme consommation"
9 CHECK (produit != conso)
10 , CONSTRAINT "FK_Ingrédient_produit"
11 FOREIGN KEY(produit)
12 REFERENCES "Produit"(ID)
13 ON UPDATE CASCADE
14 , CONSTRAINT "FK_Ingrédient_conso"
15 FOREIGN KEY(conso)
16 REFERENCES "Produit"(ID)
17 ON UPDATE CASCADE
18 );
19 CREATE UNIQUE INDEX "Ingrédient_index_produit_et_conso"
20 ON "Ingrédient"(produit,conso);