-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.sql
More file actions
154 lines (138 loc) · 7.89 KB
/
data.sql
File metadata and controls
154 lines (138 loc) · 7.89 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
drop table if exists users;
drop table if exists categories;
drop table if exists products;
drop table if exists product_ratings;
drop table if exists orders;
drop table if exists order_details;
drop table if exists contacts;
drop table if exists carts;
drop table if exists cart_products;
drop table if exists images;
create table users
(
id int auto_increment primary key,
email varchar(50) not null,
password varchar(50) not null,
last_name varchar(50) not null,
first_name varchar(50) not null,
phone varchar(20) null,
role enum ('user', 'admin') default 'user' not null,
salt varchar(50) null,
avatar json null,
cart_id int null,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null,
unique (email)
);
create table categories
(
id int auto_increment primary key,
name varchar(100) not null,
description text null,
icon json null,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null,
total_product int default 0 not null
);
create table products
(
id int auto_increment primary key,
name varchar(255) not null,
description text null,
price float not null,
quantity int not null,
images json not null,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null,
total_rating int default 0 not null,
category_id int not null
);
create table product_ratings
(
id int auto_increment primary key,
user_id int not null,
product_id int not null,
detail_id int not null,
point float default 0 null,
comment text null,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null
);
create table orders
(
id int auto_increment primary key,
user_id int not null,
contact_id int not null,
total_price float not null,
comment text null,
status int default 0 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null,
order_status int default 1
);
create table order_details
(
id int auto_increment primary key,
order_id int not null,
product_origin json null,
price float not null,
quantity int not null,
discount float default 0 null,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null
);
create table contacts (
id int auto_increment primary key,
user_id int not null,
name varchar(255) not null,
addr varchar(255) not null,
phone varchar(20) null,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null
);
create table carts
(
id int auto_increment primary key,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null,
total_product int default 0 not null
);
create table cart_products
(
cart_id int not null,
product_id int not null,
quantity int not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null,
primary key (cart_id, product_id)
);
create table favorites
(
id int auto_increment primary key,
user_id int not null,
status int default 1 not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null,
total_product int default 0 not null
);
create table favorite_products
(
favorite_id int auto_increment primary key,
product_id int not null,
created_at timestamp default current_timestamp null,
updated_at timestamp default current_timestamp on update current_timestamp null
);
create table images (
id int auto_increment primary key,
url text not null,
width int not null,
height int not null,
cloud_name char(50) not null
);