-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql database (ecom)
395 lines (283 loc) · 10.4 KB
/
sql database (ecom)
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.1
-- Dumped by pg_dump version 14.1
-- Started on 2022-05-27 21:20:52
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 216 (class 1259 OID 33332)
-- Name: carts; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.carts (
id integer NOT NULL,
cart_id integer,
user_id integer,
order_id integer,
product_id integer,
product_qty integer,
created_at timestamp without time zone DEFAULT now()
);
ALTER TABLE public.carts OWNER TO postgres;
--
-- TOC entry 215 (class 1259 OID 33331)
-- Name: carts_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.carts_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.carts_id_seq OWNER TO postgres;
--
-- TOC entry 3349 (class 0 OID 0)
-- Dependencies: 215
-- Name: carts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.carts_id_seq OWNED BY public.carts.id;
--
-- TOC entry 214 (class 1259 OID 33314)
-- Name: orders; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.orders (
id integer NOT NULL,
order_id integer,
product_id integer,
product_qty integer,
user_id integer,
created_at timestamp without time zone DEFAULT now()
);
ALTER TABLE public.orders OWNER TO postgres;
--
-- TOC entry 213 (class 1259 OID 33313)
-- Name: orders_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.orders_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.orders_id_seq OWNER TO postgres;
--
-- TOC entry 3350 (class 0 OID 0)
-- Dependencies: 213
-- Name: orders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.orders_id_seq OWNED BY public.orders.id;
--
-- TOC entry 210 (class 1259 OID 16718)
-- Name: products; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.products (
id integer NOT NULL,
sku integer,
artist character varying(255) NOT NULL,
album character varying(255) NOT NULL,
genre character varying(50),
year integer,
price numeric
);
ALTER TABLE public.products OWNER TO postgres;
--
-- TOC entry 209 (class 1259 OID 16717)
-- Name: products_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.products_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.products_id_seq OWNER TO postgres;
--
-- TOC entry 3351 (class 0 OID 0)
-- Dependencies: 209
-- Name: products_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.products_id_seq OWNED BY public.products.id;
--
-- TOC entry 212 (class 1259 OID 24901)
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.users (
id integer NOT NULL,
username character varying(30),
password text,
first_name character varying(100),
last_name character varying(100),
address character varying(255),
email character varying(50),
phone_num integer
);
ALTER TABLE public.users OWNER TO postgres;
--
-- TOC entry 211 (class 1259 OID 24900)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.users_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.users_id_seq OWNER TO postgres;
--
-- TOC entry 3352 (class 0 OID 0)
-- Dependencies: 211
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
--
-- TOC entry 3183 (class 2604 OID 33335)
-- Name: carts id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.carts ALTER COLUMN id SET DEFAULT nextval('public.carts_id_seq'::regclass);
--
-- TOC entry 3181 (class 2604 OID 33317)
-- Name: orders id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.orders ALTER COLUMN id SET DEFAULT nextval('public.orders_id_seq'::regclass);
--
-- TOC entry 3179 (class 2604 OID 16721)
-- Name: products id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.products ALTER COLUMN id SET DEFAULT nextval('public.products_id_seq'::regclass);
--
-- TOC entry 3180 (class 2604 OID 24904)
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
--
-- TOC entry 3343 (class 0 OID 33332)
-- Dependencies: 216
-- Data for Name: carts; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.carts VALUES (1, 1, 4, 1, 6, 1, '2022-05-04 22:11:43.480452');
INSERT INTO public.carts VALUES (2, 1, 4, 1, 9, 2, '2022-05-04 22:11:43.480452');
INSERT INTO public.carts VALUES (3, 2, 1, 2, 2, 1, '2022-05-04 22:11:43.480452');
--
-- TOC entry 3341 (class 0 OID 33314)
-- Dependencies: 214
-- Data for Name: orders; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.orders VALUES (4, 1, 6, 1, 4, '2022-05-04 22:03:37.769855');
INSERT INTO public.orders VALUES (5, 1, 9, 2, 4, '2022-05-04 22:03:37.769855');
INSERT INTO public.orders VALUES (6, 2, 2, 1, 1, '2022-05-04 22:03:37.769855');
--
-- TOC entry 3337 (class 0 OID 16718)
-- Dependencies: 210
-- Data for Name: products; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.products VALUES (1, 2027, 'Muse', 'Origin of Symetry', 'Alternative Rock', 2001, 5.99);
INSERT INTO public.products VALUES (2, 4422, 'Bonobo', 'Migration', 'Downtempo', 2017, 9.99);
INSERT INTO public.products VALUES (4, 1274, 'Alcest', 'Les Voyages De LAme', 'Shoegaze', 2012, 7.99);
INSERT INTO public.products VALUES (5, 1465, 'In Flames', 'Come Clarity', 'Melodic Death Metal', 2006, 5.99);
INSERT INTO public.products VALUES (6, 1590, 'Jon Hopkins', 'Immunity', 'Microhouse', 2013, 3.99);
INSERT INTO public.products VALUES (7, 2041, 'Linkin Park', 'Hybrid Theory', 'Alternative Rock', 2000, 2.99);
INSERT INTO public.products VALUES (8, 1696, 'Moby', 'Play', 'Electronica', 1999, 5.99);
INSERT INTO public.products VALUES (9, 4774, 'Olafur Arnalds', 're:member', 'Modern Classical', 2018, 8.99);
INSERT INTO public.products VALUES (10, 3729, 'Orla Gartland', 'Woman on the Internet ', 'Alternative Pop', 2021, 12.99);
INSERT INTO public.products VALUES (11, 1274, 'Alcest', 'Les Voyages De LAme', 'Shoegaze', 2012, 7.99);
INSERT INTO public.products VALUES (3, 3186, 'Lianne La Havas', 'Blood', 'Neo-Soul', 2015, 5.99);
--
-- TOC entry 3339 (class 0 OID 24901)
-- Dependencies: 212
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--
INSERT INTO public.users VALUES (1, 'gmacdiarmid0', 'OXirmIDD3', 'Godfrey', 'MacDiarmid', '7 Jackson Place', 'gmacdiarmid0@reference.com', 17282729);
INSERT INTO public.users VALUES (3, 'zlamplugh2', '4yeHnx1hw1bo', 'Zenia', 'Lamplugh', '5 Hudson Parkway', 'zlamplugh2@a8.net', 72617252);
INSERT INTO public.users VALUES (4, 'prowntree9', 'fLPiT6eyR', 'Pincus', 'Rowntree', '6 Armistice Place', 'prowntree9@omniture.com', 49848175);
INSERT INTO public.users VALUES (2, 'kkalkofer1', NULL, 'Konstantine', 'Kalkofer', '5 Pine View Lane', 'kkalkofer1@cargocollective.com', 84967332);
--
-- TOC entry 3353 (class 0 OID 0)
-- Dependencies: 215
-- Name: carts_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.carts_id_seq', 3, true);
--
-- TOC entry 3354 (class 0 OID 0)
-- Dependencies: 213
-- Name: orders_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.orders_id_seq', 6, true);
--
-- TOC entry 3355 (class 0 OID 0)
-- Dependencies: 209
-- Name: products_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.products_id_seq', 13, true);
--
-- TOC entry 3356 (class 0 OID 0)
-- Dependencies: 211
-- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--
SELECT pg_catalog.setval('public.users_id_seq', 6, true);
--
-- TOC entry 3192 (class 2606 OID 33338)
-- Name: carts carts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.carts
ADD CONSTRAINT carts_pkey PRIMARY KEY (id);
--
-- TOC entry 3190 (class 2606 OID 33320)
-- Name: orders orders_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.orders
ADD CONSTRAINT orders_pkey PRIMARY KEY (id);
--
-- TOC entry 3186 (class 2606 OID 16725)
-- Name: products products_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.products
ADD CONSTRAINT products_pkey PRIMARY KEY (id);
--
-- TOC entry 3188 (class 2606 OID 24908)
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- TOC entry 3196 (class 2606 OID 33344)
-- Name: carts carts_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.carts
ADD CONSTRAINT carts_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id);
--
-- TOC entry 3195 (class 2606 OID 33339)
-- Name: carts carts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.carts
ADD CONSTRAINT carts_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- TOC entry 3193 (class 2606 OID 33321)
-- Name: orders orders_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.orders
ADD CONSTRAINT orders_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id);
--
-- TOC entry 3194 (class 2606 OID 33326)
-- Name: orders orders_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY public.orders
ADD CONSTRAINT orders_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
-- Completed on 2022-05-27 21:20:53
--
-- PostgreSQL database dump complete
--