-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database_e-commerce.sql
85 lines (66 loc) · 2.77 KB
/
Database_e-commerce.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
77
78
79
80
81
82
83
84
/*==============================================================*/
/* Nom de SGBD : MySQL 5.0 */
/* Date de cr�ation : 01/03/2022 12:30:44 */
/*==============================================================*/
drop table if exists Customers;
drop table if exists OrderDetails;
drop table if exists Orders;
drop table if exists Products;
/*==============================================================*/
/* Table : Customers */
/*==============================================================*/
create table Customers
(
customerCode int not null AUTO_INCREMENT ,
lastName varchar(100) not null,
firstName varchar(100) not null,
adress varchar(254) not null,
phone varchar(15) not null,
email varchar(254) not null,
password varchar(254) not null,
primary key (customerCode)
);
/*==============================================================*/
/* Table : OrderDetails */
/*==============================================================*/
create table OrderDetails
(
orderID int not null,
productID int not null,
orderedQuantity int,
primary key (orderID, productID)
);
/*==============================================================*/
/* Table : Orders */
/*==============================================================*/
create table Orders
(
orderID int not null AUTO_INCREMENT,
customerCode int not null,
orderDate datetime,
deliveryAddress varchar(254),
primary key (orderID)
);
/*==============================================================*/
/* Table : Products */
/*==============================================================*/
create table Products
(
productID int not null AUTO_INCREMENT,
productName varchar(254),
description varchar(254),
unitPrice numeric(8,0),
quantityInStock int,
image varchar(254),
primary key (productID)
);
alter table OrderDetails add constraint FK_Contient foreign key (orderID)
references Orders (orderID) on delete restrict on update restrict;
alter table OrderDetails add constraint FK_commande_dans foreign key (productID)
references Products (productID) on delete restrict on update restrict;
alter table Orders add constraint FK_commander foreign key (customerCode)
references Customers (customerCode) on delete restrict on update restrict;
/*Delete From OrderDetail;
Delete From Orders;
Delete From Products;
Delete From Customers;*/