-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathderby_commands.txt
435 lines (377 loc) · 23.2 KB
/
derby_commands.txt
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
/** bid: unique identifier of Book (like ISBN)
* title: title of Book
* price: unit price WHEN ordered
* author: name of authors
* category: as specified
*/
DROP TABLE BOOK;
CREATE TABLE Book (
bid VARCHAR(20) NOT NULL,
title VARCHAR(100) NOT NULL,
price INT NOT NULL,
category VARCHAR(12) CONSTRAINT category_ck CHECK (category IN ('Science','Fiction','Engineering')) NOT NULL,
PRIMARY KEY(bid)
);
#
# Adding data for table 'Book'
#
INSERT INTO Book (bid, title, price, category) VALUES ('1500982415', 'Engineering Possibilities: Soft Skills for Young Engineers', 20, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0176509909', 'Canadian Professional Engineering and Geoscience', 140, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0073398209', 'Shigley''s Mechanical Engineering Design', 302, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0133575225', 'Introduction to Professional Engineering in Canada', 89, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0133575233', 'Practical Law of Architecture, Engineering, and Geoscience', 84, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('9384588962', 'Engineering Drawing with Auto Cad', 55, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0201835959', 'The Mythical Man-Month: Essays on Software Engineering', 32, 'Engineering');
<-------------NEW INSERTS-------------------------------->
INSERT INTO Book (bid, title, price, category) VALUES ('0345479173', 'Trump: The Art of the Deal', 1, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0199578699', 'Engineering: A Very Short Introduction', 8, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0756689015', 'Science: The Definitive Visual Guide', 18, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('0195447549', 'Engineering Economic Analysis', 148, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0470474246', 'Cryptography Engineering: Design Principles and Practical Applications', 39, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('1851686622', 'Engineering: A Beginner''s Guide', 19, 'Engineering');
INSERT INTO Book (bid, title, price, category) VALUES ('0062024329', 'The Alchemist: A Graphic Novel', 21, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0261102214', 'The Hobbit', 12, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0261102354', 'The Fellowship of the Ring', 12, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0261102362', 'The Two Towers', 12, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0261102370', 'The Return of the King', 12, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0316769487', 'The Catcher in the Rye', 8, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0446310786', 'To Kill a Mockingbird', 8, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0553103547', 'A Game of Thrones: A Song of Ice and Fire', 30, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0553106635', 'A Storm of Swords: A Song of Ice and Fire', 28, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0553108034', 'A Clash of Kings: A Song of Ice and Fire', 28, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0553418025', 'The Martian: A Novel', 10, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0553805444', 'The World of Ice & Fire', 37, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('1338099132', 'Harry Potter and the Cursed Child', 24, 'Fiction');
INSERT INTO Book (bid, title, price, category) VALUES ('0022880097', 'Science: A Closer Look 5', 118, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('0393081087', 'The Food Lab', 39, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('0756698413', 'Universe', 33, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1250007135', 'Undeniable: Evolution and the Science of Creation', 19, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1465414371', 'Earth (Second Edition)', 33, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1465419683', 'Ocean', 46, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1465424644', 'The Planets', 19, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1465428267', '101 Great Science Experiments', 11, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1554077486', 'The Universe and Beyond', 19, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1770854339', 'Hubble''s Universe: Greatest Discoveries and Latest Images', 20, 'Science');
INSERT INTO Book (bid, title, price, category) VALUES ('1591263336', 'Rapid Preparation for the Fundamentals of Engineering Exam', 122, 'Engineering');
<<<<<<< HEAD
INSERT INTO Book (bid, title, price, category) VALUES ('1118787315', 'Practical Reverse Engineering', 50, 'Engineering');
=======
>>>>>>> 8e5a4a1c03ac9b3ec3ffcde0f5ad9cb41c1d42fd
#
/* Address
* id: address id
*
*/
DROP TABLE Address;
CREATE TABLE Address (
id INT CONSTRAINT id_ck CHECK (id > 0) NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
street VARCHAR(100) NOT NULL,
province VARCHAR(20) NOT NULL,
country VARCHAR(20) NOT NULL,
zip VARCHAR(20) NOT NULL,
phone VARCHAR(20),
PRIMARY KEY(id)
);
#
# Inserting data for table 'address'
#
INSERT INTO Address (street, province, country, zip, phone) VALUES ('123 Yonge St', 'ON',
'Canada', 'K1E 6T5' ,'647-123-4567');
INSERT INTO Address (street, province, country, zip, phone) VALUES ('445 Avenue rd', 'ON',
'Canada', 'M1C 6K5' ,'416-123-8569');
INSERT INTO Address (street, province, country, zip, phone) VALUES ('789 Keele St.', 'ON',
'Canada', 'K3C 9T5' ,'416-123-9568');
#
#
/* Purchase Order
* lname: last name
* fname: first name
* id: purchase order id
* status:status of purchase
*/
DROP TABLE PO;
CREATE TABLE PO (
id INT CONSTRAINT POid_ck CHECK (id > 0) NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
lname VARCHAR(20) NOT NULL,
fname VARCHAR(20) NOT NULL,
status VARCHAR(10) CONSTRAINT status_ck CHECK (status IN ('ORDERED','PROCESSED','DENIED')) NOT NULL,
address INT CONSTRAINT address_ck CHECK (address > 0) NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY (address) REFERENCES Address (id) ON DELETE CASCADE
);
CREATE INDEX PO_IDX ON PO(address);
#
# Inserting data for table 'PO'
#
insert into po (lname, fname, status, address) values ('michel', 'alsamad', 'ORDERED', 1);
#
#
/* Items on order
* id : purchase order id
* bid: unique identifier of Book
* price: unit price
*/
DROP TABLE POItem;
CREATE TABLE POItem (
id INT CONSTRAINT POItemid_ck CHECK (id > 0) NOT NULL,
bid VARCHAR(20) NOT NULL,
quantity INT CONSTRAINT quantity_ck CHECK (quantity > 0) NOT NULL,
unitPrice INT CONSTRAINT POItemprice_ck CHECK (unitPrice > 0) NOT NULL,
final_price INT GENERATED ALWAYS AS (quantity * unitPrice),
user_name VARCHAR(250),
PRIMARY KEY(id),
FOREIGN KEY(id) REFERENCES PO(id) ON DELETE CASCADE,
FOREIGN KEY(bid) REFERENCES book(bid) ON DELETE CASCADE)
;
CREATE INDEX POitem_IDX_id ON POItem(id);
CREATE INDEX POitem_IDX_bid ON POItem(bid);
#
# Inserting data for table 'POitem'
#
insert into poitem (id, bid, quantity, unitprice,user_name) values (3, '0345479173', 3, 1,'michel');
#
#
/* visit to website
* day: date
* bid: unique identifier of Book
* eventtype: status of purchase
*/
Inserting TABLE if exists VisitEvent;
CREATE TABLE VisitEvent (
date date default current_date NOT NULL,
bid varchar(20) not null REFERENCES Book(bid),
event_type VARCHAR(9) CONSTRAINT event_type_ck CHECK (event_type IN ('VIEW','CART','PURCHASE')) NOT NULL,
FOREIGN KEY(bid) REFERENCES Book(bid)
);
#
# Dumping data for table 'VisitEvent'
#
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575225','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575225','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575225','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575225','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575225','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0133575233','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0176509909','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0176509909','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0176509909','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0176509909','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0176509909','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0199578699','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0201835959','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0316769487','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1465414371','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1554077486','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('1591263336','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0553805444','VIEW' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0073398209','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575225','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575225','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575225','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575225','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0133575233','CART' );
insert into VISITEVENT (bid,event_type) values ('0176509909','CART' );
insert into VISITEVENT (bid,event_type) values ('0176509909','CART' );
insert into VISITEVENT (bid,event_type) values ('0176509909','CART' );
insert into VISITEVENT (bid,event_type) values ('0176509909','CART' );
insert into VISITEVENT (bid,event_type) values ('0176509909','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0199578699','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0201835959','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('0316769487','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1465414371','CART' );
insert into VISITEVENT (bid,event_type) values ('1554077486','CART' );
insert into VISITEVENT (bid,event_type) values ('1554077486','CART' );
insert into VISITEVENT (bid,event_type) values ('1554077486','CART' );
insert into VISITEVENT (bid,event_type) values ('1554077486','CART' );
insert into VISITEVENT (bid,event_type) values ('1554077486','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('1591263336','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
insert into VISITEVENT (bid,event_type) values ('0553805444','CART' );
#
#
/*
* user name and password table
*/
CREATE TABLE accounts (
userName VARCHAR(255) NOT NULL ,
password VARCHAR(20) NOT NULL,
account_type VARCHAR(7) CONSTRAINT type_ck CHECK (account_type IN ('user', 'admin','partner')) NOT NULL,
PRIMARY KEY(userName));
CREATE TABLE user_roles (
userName VARCHAR(255) NOT NULL,
role VARCHAR(20) NOT NULL,
PRIMARY KEY (userName, role)
);
insert into accounts (userName, password, account_type) values ('admin','admin','admin');
insert into accounts (userName, password, account_type) values ('user1','abc123','user');
insert into accounts (userName, password, account_type) values ('partner1','abc123','partner');
insert into user_roles (userName, role) values ('admin','admin');
insert into user_roles (userName, role) values ('user1','user');
insert into user_roles (userName, role) values ('partner1','partner');
/*
* reviews table
*/
CREATE TABLE reviews(
id INT CONSTRAINT reviewid_ck CHECK (id > 0) NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
bid VARCHAR(20) NOT NULL,
review VARCHAR(20000),
stars INT CONSTRAINT stars_ck CHECK (stars > -1 AND stars < 6),
PRIMARY KEY(id),
FOREIGN KEY (bid) REFERENCES book (bid)
);