-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBD.sql
More file actions
71 lines (64 loc) · 2.43 KB
/
BD.sql
File metadata and controls
71 lines (64 loc) · 2.43 KB
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
61
62
63
64
65
66
67
68
69
70
71
/*drop table Evenement;
drop table Utilisateur;
drop table Fournisseur;
drop table Produit;
drop table CommandeFourn;
drop table RetourVidange;
drop table LigneProduit;*/
CREATE TABLE Utilisateur
(Login varchar(20) not NULL constraint Utilisateur_Pk primary key,
Password varchar(20) not NULL,
Nom varchar(30) not NULL,
Prenom varchar(30) not NULL,
Fonction varchar(30) not NULL);
CREATE TABLE Fournisseur
(Nom varchar(20) not NULL constraint Fournisseur_Pk primary key,
Rue varchar(50) not NULL,
CodePostal numeric(4) not NULL,
Localite varchar(50) not NULL);
CREATE TABLE Produit
(Reference int not NULL constraint Produit_Pk primary key
GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1),
Libelle varchar(30) not NULL,
PrixBase numeric(5,2) not NULL,
PrixVidange numeric(5,2),
TVA numeric(4) not NULL,
Reduction BOOLEAN not NULL,
DateFinReduc date,
PourcReduc numeric(5,2),
QteStock numeric(5) not NULL,
QteMinStock numeric(5) not NULL);
CREATE TABLE CommandeFourn
(Numéro int not NULL constraint CommandeFourn_Pk primary key
GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1),
DateCommande date not NULL,
Utilisateur varchar(20) not NULL,
Fournisseur varchar(20) not NULL,
Etat varchar(12) not NULL,
constraint CommandeFourn_FK_Utilisateur foreign key(Utilisateur) references Utilisateur,
constraint CommandeFourn_FK_Fournisseur foreign key(Fournisseur) references Fournisseur);
CREATE TABLE RetourVidange
(Fournisseur varchar(20) not NULL,
Produit int not NULL,
Utilisateur varchar(20) not NULL,
DateRetVid date not NULL,
Quantite numeric(4) not NULL,
constraint RetourVidange_Pk primary key (Fournisseur, Produit, Utilisateur),
constraint RetourVidange_FK_Utilisateur foreign key(Utilisateur) references Utilisateur,
constraint RetourVidange_FK_Produit foreign key(Produit) references Produit,
constraint RetourVidange_FK_Fournisseur foreign key(Fournisseur) references Fournisseur);
CREATE TABLE LigneProduit
(Produit int not NULL,
CommandeFourn int not NULL,
Quantite numeric(3) not NULL,
constraint LigneProduit_Pk primary key (CommandeFourn, Produit),
constraint LigneProduit_FK_Produit foreign key(Produit) references Produit,
constraint LigneProduit_FK_CommandeFourn foreign key(CommandeFourn) references CommandeFourn);
CREATE TABLE Evenement
(Nom varchar(50) not NULL constraint Evenement_Pk primary key,
Lieu varchar(50) not NULL,
DateEvenement date not NULL,
Thematique varchar(50) not NULL,
NbPersAttendues numeric(8));