-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.txt
More file actions
226 lines (155 loc) · 4.58 KB
/
Copy pathdatabase.txt
File metadata and controls
226 lines (155 loc) · 4.58 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
-- public.account definition
-- Drop table
-- DROP TABLE public.account;
CREATE TABLE public.account (
account_id int4 NOT NULL,
firstname varchar NULL,
lastname varchar NULL,
username varchar NOT NULL,
"password" varchar NOT NULL,
email varchar NULL,
phone varchar NULL,
created_in date NULL,
updated_in date NULL,
CONSTRAINT account_pk PRIMARY KEY (account_id)
);
-- public.brand definition
-- Drop table
-- DROP TABLE public.brand;
CREATE TABLE public.brand (
brand_id int4 NOT NULL,
bname varchar NOT NULL,
created_in date NULL,
updated_in date NULL,
CONSTRAINT brand_pk PRIMARY KEY (brand_id)
);
-- public.category definition
-- Drop table
-- DROP TABLE public.category;
CREATE TABLE public.category (
category_id int4 NOT NULL,
cname varchar NOT NULL,
description varchar NULL,
created_in date NULL,
updated_in date NULL,
CONSTRAINT category_pk PRIMARY KEY (category_id)
);
-- public.erole definition
-- Drop table
-- DROP TABLE public.erole;
CREATE TABLE public.erole (
);
-- public.image definition
-- Drop table
-- DROP TABLE public.image;
CREATE TABLE public.image (
image_id int4 NOT NULL,
"data" bytea NOT NULL,
content_type varchar NULL,
"size" int4 NULL,
CONSTRAINT image_pk PRIMARY KEY (image_id)
);
-- public.paying_type definition
-- Drop table
-- DROP TABLE public.paying_type;
CREATE TABLE public.paying_type (
);
-- public."role" definition
-- Drop table
-- DROP TABLE public."role";
CREATE TABLE public."role" (
role_id int4 NOT NULL,
rname varchar NOT NULL,
CONSTRAINT role_pk PRIMARY KEY (role_id)
);
-- public.shipping_type definition
-- Drop table
-- DROP TABLE public.shipping_type;
CREATE TABLE public.shipping_type (
);
-- public.account_role definition
-- Drop table
-- DROP TABLE public.account_role;
CREATE TABLE public.account_role (
account_id int4 NOT NULL,
role_id int4 NOT NULL,
CONSTRAINT account_role_pk PRIMARY KEY (role_id, account_id),
CONSTRAINT account_role_fk FOREIGN KEY (account_id) REFERENCES public.account(account_id),
CONSTRAINT account_role_fk_1 FOREIGN KEY (role_id) REFERENCES public."role"(role_id)
);
-- public.cart definition
-- Drop table
-- DROP TABLE public.cart;
CREATE TABLE public.cart (
cart_id int4 NOT NULL,
account_id int4 NOT NULL,
"valid" bool NULL,
CONSTRAINT carts_pk PRIMARY KEY (cart_id),
CONSTRAINT cart_fk FOREIGN KEY (account_id) REFERENCES public.account(account_id)
);
-- public."order" definition
-- Drop table
-- DROP TABLE public."order";
CREATE TABLE public."order" (
order_id int4 NOT NULL,
cart_id int4 NOT NULL,
name varchar(255) NOT NULL,
phone varchar(11) NOT NULL,
note varchar(500) NULL,
shipping_type varchar(255) NOT NULL,
paying_type varchar(255) NOT NULL,
cancel_reason varchar(500) NULL,
shipping_fee int8 NOT NULL,
address_city varchar(255) NOT NULL,
address_province varchar(255) NOT NULL,
address_ward varchar(255) NOT NULL,
address varchar(255) NOT NULL,
total_price int8 NOT NULL,
CONSTRAINT orders_pk PRIMARY KEY (order_id),
CONSTRAINT orders_fk FOREIGN KEY (cart_id) REFERENCES public.cart(cart_id)
);
-- public.product definition
-- Drop table
-- DROP TABLE public.product;
CREATE TABLE public.product (
product_id int4 NOT NULL,
pname varchar(255) NOT NULL,
category_id int4 NOT NULL,
price int8 NULL,
rating_star float4 NULL,
image_id int4 NULL,
created_in date NULL,
updated_in date NULL,
description varchar NULL,
brand_id int4 NOT NULL,
CONSTRAINT products_pk PRIMARY KEY (product_id),
CONSTRAINT product_fk FOREIGN KEY (brand_id) REFERENCES public.brand(brand_id),
CONSTRAINT product_fk_1 FOREIGN KEY (category_id) REFERENCES public.category(category_id),
CONSTRAINT product_fk_2 FOREIGN KEY (image_id) REFERENCES public.image(image_id)
);
-- public.rating definition
-- Drop table
-- DROP TABLE public.rating;
CREATE TABLE public.rating (
rating_id int4 NOT NULL,
product_id int4 NOT NULL,
account_id int4 NOT NULL,
"date" date NULL,
star int4 NOT NULL,
"comment" varchar NULL,
CONSTRAINT rating_pk PRIMARY KEY (rating_id),
CONSTRAINT rating_fk FOREIGN KEY (account_id) REFERENCES public.account(account_id),
CONSTRAINT rating_fk_1 FOREIGN KEY (product_id) REFERENCES public.product(product_id)
);
-- public.cart_item definition
-- Drop table
-- DROP TABLE public.cart_item;
CREATE TABLE public.cart_item (
product_id int4 NOT NULL,
cart_id int4 NOT NULL,
quantity int4 NOT NULL,
cart_item_id int4 NOT NULL,
CONSTRAINT cart_items_pk PRIMARY KEY (cart_item_id),
CONSTRAINT cart_item_fk FOREIGN KEY (cart_id) REFERENCES public.cart(cart_id),
CONSTRAINT cart_item_fk_1 FOREIGN KEY (product_id) REFERENCES public.product(product_id)
);