-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sql
More file actions
71 lines (60 loc) · 2.04 KB
/
Copy pathscript.sql
File metadata and controls
71 lines (60 loc) · 2.04 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 if exists Client, Ligne, Commande, Prestation, Carte;
create table Carte(
codeCarte int not null AUTO_INCREMENT,
carte varchar(10),
remise int(3),
primary key (codeCarte)
) CHARACTER SET utf8 COLLATE utf8_bin;
create table Client(
codeClient int not null AUTO_INCREMENT,
civilite varchar(8),
nom varchar(15),
prenom varchar(15),
adresse varchar(50),
codePostal int(5),
ville varchar(15),
carte int,
primary key (codeClient),
foreign key (carte) references Carte(codeCarte)
) CHARACTER SET utf8 COLLATE utf8_bin;
create table Prestation(
codePrestation int not null AUTO_INCREMENT,
prestation varchar(30),
prix decimal(4,1),
primary key (codePrestation)
) CHARACTER SET utf8 COLLATE utf8_bin;
create table Commande(
numCommande int not null AUTO_INCREMENT,
prixTotal double,
dateCommande DATETIME,
codeClient int,
primary key (numCommande),
foreign key (codeClient) references Client(codeClient)
);
create table Ligne(
numCommande int,
codePrestation int,
quantite int,
primary key (numCommande,codePrestation),
foreign key (numCommande) references Commande(numCommande),
foreign key (codePrestation) references Prestation(codePrestation)
);
insert into Carte values (1,'verte',10),
(2,'bleue',25),
(3,'orange',34),
(4,'rouge',50);
insert into Client values (1,'Monsieur','Bertin','Théophile','12 rue des près', 90000, 'Belfort', 1),
(2,'Monsieur','Bischoffe','Maxime','7 rue de la madeleine', 90150, 'Denney', 3),
(3,'Madame','Bitsch','Magali','8 rue des pervenches', 90400, 'Anjoutay', 2),
(4,'Madame','Briswalter','Melody','12 rue des moulinets', 90180, 'Banvillars', 2),
(5,'Monsieur','Concolato','Florian','7 rue des vergers', 90450, 'Baviliers', 1),
(6,'Madame','Fichter','Cécile','9 rue de la moselle',90100,'Delle',4),
(7,'Madame','Furster','Eline','12 rue des feuilles',90000,'Belfort',2),
(8,'Madame','Jacquot','Sophie','25 rue du piton',90150,'Etueffont',4);
insert into Prestation values(1,'raquettes',3.0),
(2,'batons par paires',3.5),
(3,'skis parboliques',3.25),
(4, 'skis de fond',4.5),
(5,'skating',6.3),
(6,'surf',7.5),
(7,'equipement pro combi',7.0);