2024-BD-BUT1-Sen/Code/TD1.sql
Pierre Valarcher 21d129ba49 Notes2 et exos
2024-09-19 15:34:05 +02:00

34 lines
841 B
SQL

BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "Personne" (
"NumPersonne" INTEGER,
"NomPersonne" VARCHAR(50),
PRIMARY KEY("NumPersonne")
);
CREATE TABLE IF NOT EXISTS "Fournisseur" (
"numF" INTEGER,
"nomF" VARCHAR(20),
"CatF" INTEGER,
"VilF" VARCHAR(15),
PRIMARY KEY("numF")
);
CREATE TABLE IF NOT EXISTS "Piece" (
"numP" INTEGER,
"nomP" VARCHAR(20),
"clrP" VARCHER(20),
"PdsP" INTEGER,
PRIMARY KEY("numP")
);
CREATE TABLE IF NOT EXISTS "Livraison" (
"numF" INTEGER,
"numP" INTEGER,
"Qte" INTEGER,
PRIMARY KEY("numF","numP"),
FOREIGN KEY("numP") REFERENCES "Piece",
FOREIGN KEY("numF") REFERENCES "Fournisseur"
);
INSERT INTO "Personne" VALUES (1,'Martin');
INSERT INTO "Fournisseur" VALUES (32,'Thales',2,'Paris');
INSERT INTO "Piece" VALUES (25,'engrenage','gris',300);
INSERT INTO "Livraison" VALUES (32,25,40);
COMMIT;