2024-BD-BUT1-Sen/Code/TD1.sql

34 lines
841 B
MySQL
Raw Normal View History

2024-09-19 15:34:05 +02:00
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;