This repository has been archived by the owner on Mar 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
78 lines (66 loc) · 2.11 KB
/
database.sql
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
72
73
74
75
76
drop table categorie;
CREATE TABLE `categorie` (
`id` int(11) auto_increment NOT NULL primary key,
`name` varchar(45) not NULL
);
drop table produit;
CREATE TABLE `produit` (
`sku` int(45) NOT NULL auto_increment primary key,
`name` varchar(45) NOT NULL,
`type` varchar(45) not NULL,
`price` float(45) not NULL,
`upc` varchar(45) not NULL,
`category` int not NULL,
`shipping` float(45) not NULL,
`description` varchar(45) not NULL,
`manufacturer` varchar(45) not NULL,
`model` varchar(45) not NULL,
`url` text not NULL,
`image` text not NULL,
FOREIGN KEY (category) REFERENCES categorie(id)
);
CREATE TABLE `utilisateur` (
`ID_USER` int(11) NOT NULL primary key,
`USERNAME` varchar(45) not NULL,
`FULL_NAME` varchar(45) not NULL,
`EMAIL` varchar(45) not NULL,
`TELEPHONE` varchar(45) not NULL,
`ROLE` varchar(45) not NULL,
`DATE_NAISSANCE` date not NULL,
`CREATED_AT_U` datetime not NULL,
`UPDATED_AT_U` datetime not NULL
) ;
CREATE TABLE `carte` (
`ID_CARTE` int(11) NOT NULL auto_increment primary key,
`ID_USER_c` int(11) NOT NULL,
FOREIGN KEY (ID_USER_c) REFERENCES utilisateur(ID_USER)
);
CREATE TABLE `contient` (
`ID_PRODUIT` int(10) NOT NULL,
`ID_CARTE` int(11) NOT NULL,
PRIMARY KEY (ID_PRODUIT,ID_CARTE),
FOREIGN KEY (ID_PRODUIT) REFERENCES produit(sku),
FOREIGN KEY (ID_CARTE) REFERENCES carte(ID_CARTE)
) ;
CREATE TABLE `ordre` (
`ID_ORDRE` int(11) NOT NULL auto_increment primary key,
`ID_USER` int(11) NOT NULL,
`QUANTITE_ORDRE` int(11) not NULL,
`EST_LIVREE` tinyint(1) not NULL,
`FULLNAME` varchar(45) not NULL,
`ADRESS` varchar(45) not NULL,
`VILLE` varchar(45) not NULL,
`PAYS` varchar(45) not NULL,
`CODE_POSTALE` int(11) not NULL,
`TELEPHONE` varchar(45) not NULL,
FOREIGN KEY (ID_USER) REFERENCES utilisateur(ID_USER)
);
CREATE TABLE `ordreproduct` (
`ID_ORDRE` int(11) NOT NULL,
`ID_PRODUIT` char(10) NOT NULL,
`CREATED_AT_` datetime not NULL,
`UPDATED_AT_` datetime DEFAULT NULL,
PRIMARY KEY (ID_PRODUIT,ID_ORDRE),
FOREIGN KEY (ID_PRODUIT) REFERENCES produit(sku),
FOREIGN KEY (ID_ORDRE) REFERENCES ordre(ID_ORDRE)
) ;