-
Notifications
You must be signed in to change notification settings - Fork 1
/
amazon_db_system.sql
902 lines (759 loc) · 22.7 KB
/
amazon_db_system.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
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
CREATE TABLE amz_user (
email VARCHAR(255) PRIMARY KEY,
fname VARCHAR(255) NOT NULL,
lname VARCHAR(255),
password VARCHAR(30) NOT NULL,
user_type NUMBER(1) NOT NULL
);
CREATE TABLE contact_detail (
user_id VARCHAR(255) NOT NULL,
address_id INTEGER PRIMARY KEY,
street1 VARCHAR(255) NOT NULL,
street2 VARCHAR(255),
city VARCHAR(50) NOT NULL,
state VARCHAR(50) NOT NULL,
country VARCHAR(50) NOT NULL,
zipcode NUMBER(5) NOT NULL,
phone VARCHAR(20) NOT NULL,
is_default NUMBER(1) DEFAULT 0
);
CREATE TABLE card_info (
card_id INTEGER PRIMARY KEY,
card_number NUMBER(16) NOT NULL,
expiry_date DATE NOT NULL,
cvv NUMBER(3) NOT NULL,
buyer_id VARCHAR(255) NOT NULL,
is_default NUMBER(1)
);
CREATE TABLE buyer (
buyer_id VARCHAR(255) PRIMARY KEY,
is_prime NUMBER(1) DEFAULT 0,
prime_expiry_date DATE
);
CREATE TABLE seller (
seller_id VARCHAR(255) PRIMARY KEY,
company_name VARCHAR(255) NOT NULL,
url VARCHAR(255),
description VARCHAR(255),
average_rating NUMBER(2, 1) DEFAULT 2.5,
rating_count NUMBER DEFAULT 0
);
CREATE TABLE category (
category_id INTEGER PRIMARY KEY,
category_name VARCHAR(255) NOT NULL
);
CREATE TABLE product (
product_id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL,
seller_id VARCHAR(255) NOT NULL,
price NUMBER(10, 2) NOT NULL,
rating NUMBER(2, 1),
review_count INTEGER,
category_id INTEGER,
description VARCHAR(255),
discount_percent NUMBER(4, 2),
available_units INTEGER,
color VARCHAR(30),
in_stock NUMBER(1),
weight NUMBER(10, 2),
carrier_id INTEGER
);
CREATE TABLE product_image (
product_id INTEGER,
image_url VARCHAR(255),
PRIMARY KEY ( product_id,
image_url )
);
CREATE TABLE shopping_cart (
buyer_id VARCHAR(255),
date_added DATE
);
CREATE TABLE product_shoppingcart (
product_id INTEGER,
buyer_id VARCHAR(255),
PRIMARY KEY ( product_id,
buyer_id )
);
CREATE TABLE wish_list (
buyer_id VARCHAR(255),
date_added DATE
);
CREATE TABLE product_wishlist (
product_id INTEGER,
buyer_id VARCHAR(255),
PRIMARY KEY ( product_id,
buyer_id )
);
CREATE TABLE amz_order (
order_id INTEGER PRIMARY KEY,
buyer_id VARCHAR(255) NOT NULL,
card_id INTEGER NOT NULL,
total_price NUMBER(10, 2),
order_date DATE,
tax NUMBER(4, 2) DEFAULT 10,
shipping_price NUMBER(4, 2) DEFAULT 10,
delivery_address_id INTEGER,
delivery_date DATE,
order_status CHAR(1) NOT NULL,
quantity INTEGER NOT NULL
);
CREATE TABLE order_product (
order_id INTEGER,
product_id INTEGER,
PRIMARY KEY ( order_id,
product_id )
);
CREATE TABLE review (
review_id INTEGER PRIMARY KEY,
product_id INTEGER NOT NULL,
buyer_id VARCHAR(255) NOT NULL,
review VARCHAR(1000),
rating NUMBER(2, 1),
review_date DATE
);
CREATE TABLE review_image (
review_id INTEGER,
image_url VARCHAR(255),
PRIMARY KEY ( review_id,
image_url )
);
CREATE TABLE carrier (
carrier_id INTEGER PRIMARY KEY,
carrier_name VARCHAR(255) NOT NULL,
carrier_phone NUMBER(10) NOT NULL,
carrier_email VARCHAR(255) NOT NULL
);
ALTER TABLE contact_detail
ADD CONSTRAINT contact_detail_user_id_fk FOREIGN KEY ( user_id )
REFERENCES amz_user ( email )
ON DELETE CASCADE;
ALTER TABLE card_info
ADD CONSTRAINT card_info_buyer_id_fk FOREIGN KEY ( buyer_id )
REFERENCES buyer ( buyer_id )
ON DELETE CASCADE;
ALTER TABLE product
ADD CONSTRAINT product_seller_id_fk FOREIGN KEY ( seller_id )
REFERENCES seller ( seller_id )
ON DELETE CASCADE;
ALTER TABLE product
ADD CONSTRAINT product_category_id_fk FOREIGN KEY ( category_id )
REFERENCES category ( category_id )
ON DELETE CASCADE;
ALTER TABLE product
ADD CONSTRAINT product_carrier_id_fk FOREIGN KEY ( carrier_id )
REFERENCES carrier ( carrier_id )
ON DELETE CASCADE;
ALTER TABLE product_image
ADD CONSTRAINT product_image_product_id_fk FOREIGN KEY ( product_id )
REFERENCES product ( product_id )
ON DELETE CASCADE;
ALTER TABLE shopping_cart
ADD CONSTRAINT shopping_cart_buyer_id_fk FOREIGN KEY ( buyer_id )
REFERENCES buyer ( buyer_id )
ON DELETE CASCADE;
ALTER TABLE product_shoppingcart
ADD CONSTRAINT product_sc_buyer_id_fk FOREIGN KEY ( buyer_id )
REFERENCES buyer ( buyer_id )
ON DELETE CASCADE;
ALTER TABLE product_shoppingcart
ADD CONSTRAINT product_sc_product_id_fk FOREIGN KEY ( product_id )
REFERENCES product ( product_id )
ON DELETE CASCADE;
ALTER TABLE wish_list
ADD CONSTRAINT wishlist_buyer_id_fk FOREIGN KEY ( buyer_id )
REFERENCES buyer ( buyer_id )
ON DELETE CASCADE;
ALTER TABLE product_wishlist
ADD CONSTRAINT product_wishlist_product_id_fk FOREIGN KEY ( product_id )
REFERENCES product ( product_id )
ON DELETE CASCADE;
ALTER TABLE product_wishlist
ADD CONSTRAINT product_wishlist_buyer_id_fk FOREIGN KEY ( buyer_id )
REFERENCES buyer ( buyer_id )
ON DELETE CASCADE;
ALTER TABLE amz_order
ADD CONSTRAINT order_buyer_id_fk FOREIGN KEY ( buyer_id )
REFERENCES buyer ( buyer_id )
ON DELETE CASCADE;
ALTER TABLE amz_order
ADD CONSTRAINT order_card_id_fk FOREIGN KEY ( card_id )
REFERENCES card_info ( card_id )
ON DELETE CASCADE;
ALTER TABLE amz_order
ADD CONSTRAINT order_delivery_address_id_fk FOREIGN KEY ( delivery_address_id )
REFERENCES contact_detail ( address_id )
ON DELETE CASCADE;
ALTER TABLE order_product
ADD CONSTRAINT order_product_order_id_fk FOREIGN KEY ( order_id )
REFERENCES amz_order ( order_id )
ON DELETE CASCADE;
ALTER TABLE order_product
ADD CONSTRAINT order_product_product_id_fk FOREIGN KEY ( product_id )
REFERENCES product ( product_id )
ON DELETE CASCADE;
ALTER TABLE review
ADD CONSTRAINT review_product_id_fk FOREIGN KEY ( product_id )
REFERENCES product ( product_id )
ON DELETE CASCADE;
ALTER TABLE review
ADD CONSTRAINT review_buyer_id_fk FOREIGN KEY ( buyer_id )
REFERENCES buyer ( buyer_id )
ON DELETE CASCADE;
ALTER TABLE review_image
ADD CONSTRAINT review_image_review_id_fk FOREIGN KEY ( review_id )
REFERENCES review ( review_id )
ON DELETE CASCADE;
CREATE OR REPLACE PROCEDURE register_buyer (
email IN VARCHAR,
fname IN VARCHAR,
lname IN VARCHAR,
password IN VARCHAR
) AS
BEGIN
INSERT INTO amz_user VALUES (
email,
fname,
lname,
password,
0
);
INSERT INTO buyer VALUES (
email,
0,
NULL
);
END register_buyer;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE register_seller (
email IN VARCHAR,
fname IN VARCHAR,
lname IN VARCHAR,
password IN VARCHAR,
company_name IN VARCHAR,
url IN VARCHAR,
description_var IN VARCHAR
) AS
BEGIN
INSERT INTO amz_user VALUES (
email,
fname,
lname,
password,
1
);
INSERT INTO seller VALUES (
email,
company_name,
url,
description_var,
2.5,
0
);
END register_seller;
---------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE add_contact_details (
user_id IN VARCHAR,
address_id IN INTEGER,
street1 IN VARCHAR,
street2 IN VARCHAR,
city IN VARCHAR,
state IN VARCHAR,
country IN VARCHAR,
zipcode IN NUMBER,
phone IN VARCHAR
) AS
BEGIN
INSERT INTO contact_detail VALUES (
user_id,
address_id,
street1,
street2,
city,
state,
country,
zipcode,
phone,
0
);
END add_contact_details;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE set_default_contact_details (
contact_id IN INTEGER,
buyer_id IN VARCHAR
) AS
BEGIN
UPDATE contact_detail
SET
is_default = 1
WHERE
user_id = buyer_id
AND address_id = contact_id;
END set_default_contact_details;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE add_card_info (
buyer_id IN VARCHAR,
card_id IN INTEGER,
card_number IN NUMBER,
expiry_date IN DATE,
cvv IN NUMBER
) AS
BEGIN
INSERT INTO card_info VALUES (
card_id,
card_number,
expiry_date,
cvv,
buyer_id,
0
);
END add_card_info;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE set_default_card_info (
card_id_var IN INTEGER,
buyer_id_var IN VARCHAR
) AS
BEGIN
UPDATE card_info
SET
is_default = 1
WHERE
buyer_id = buyer_id_var
AND card_id = card_id_var;
END set_default_card_info;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE add_product (
product_id IN INTEGER,
name IN VARCHAR,
seller_id IN VARCHAR,
price IN NUMBER,
category_id IN INTEGER,
description IN VARCHAR,
available_units IN INTEGER,
color IN VARCHAR,
weight IN NUMBER,
carrier_id IN INTEGER,
image_url IN VARCHAR
) AS
BEGIN
INSERT INTO product VALUES (
product_id,
name,
seller_id,
price,
0,
0,
category_id,
description,
0,
available_units,
color,
1,
weight,
carrier_id
);
INSERT INTO product_image VALUES (
product_id,
image_url
);
END add_product;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE add_to_shopping_cart (
buyer_id IN VARCHAR,
product_id IN INTEGER
) AS
BEGIN
INSERT INTO shopping_cart VALUES (
buyer_id,
sysdate
);
INSERT INTO product_shoppingcart VALUES (
product_id,
buyer_id
);
END add_to_shopping_cart;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE add_to_wish_list (
buyer_id IN VARCHAR,
product_id IN INTEGER
) AS
BEGIN
INSERT INTO wish_list VALUES (
buyer_id,
sysdate
);
INSERT INTO product_wishlist VALUES (
product_id,
buyer_id
);
END add_to_wish_list;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE give_review (
review_id IN NUMBER,
product_id IN INTEGER,
buyer_id IN VARCHAR,
review IN VARCHAR,
rating IN NUMBER,
image_url IN VARCHAR
) AS
BEGIN
INSERT INTO review VALUES (
review_id,
product_id,
buyer_id,
review,
rating,
sysdate
);
INSERT INTO review_image VALUES (
review_id,
image_url
);
END give_review;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE TRIGGER update_product_rating AFTER
INSERT ON review
FOR EACH ROW
DECLARE
new_rating NUMBER(2, 1);
review_count_old INTEGER;
BEGIN
SELECT
review_count
INTO review_count_old
FROM
product
WHERE
product_id = :new.product_id;
new_rating := :new.rating;
UPDATE product
SET
rating = ( ( rating * review_count_old ) + new_rating ) / ( review_count_old + 1 ),
review_count = review_count_old + 1
WHERE
product_id = :new.product_id;
END;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE TRIGGER update_seller_rating AFTER
INSERT OR UPDATE OF rating ON review
FOR EACH ROW
DECLARE
new_rating NUMBER(2, 1);
seller_id_to_update VARCHAR(255);
BEGIN
new_rating := :new.rating;
SELECT
seller_id
INTO seller_id_to_update
FROM
product
WHERE
product_id = :new.product_id;
UPDATE seller
SET
average_rating = ( ( average_rating * rating_count ) + new_rating ) / ( rating_count + 1 ),
rating_count = rating_count + 1
WHERE
seller_id = seller_id_to_update;
END;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE update_membership (
buyer_id_input IN VARCHAR
) AS
BEGIN
UPDATE buyer
SET
is_prime = 1,
prime_expiry_date = add_months(DATE '2019-11-28', 12)
WHERE
buyer_id = buyer_id_input;
END update_membership;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE cancel_membership (
buyer_id_input IN VARCHAR
) AS
BEGIN
UPDATE buyer
SET
is_prime = 0,
prime_expiry_date = NULL
WHERE
buyer_id = buyer_id_input;
END cancel_membership;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE place_order (
order_id IN INTEGER,
buyer_id_var IN VARCHAR
) AS
card_id_var INTEGER;
address_id_var INTEGER;
total_price_var NUMBER := 0;
curr_price_var NUMBER;
total_qty_var NUMBER := 0;
available_units_var NUMBER(1);
shipping_price_var NUMBER := 10;
is_prime_var NUMBER := 0;
CURSOR products_cur IS
SELECT
product_id
FROM
product_shoppingcart
WHERE
buyer_id = buyer_id_var;
product_id_var INTEGER;
BEGIN
OPEN products_cur;
LOOP
FETCH products_cur INTO product_id_var;
EXIT WHEN products_cur%notfound;
SELECT
price,
available_units
INTO
curr_price_var,
available_units_var
FROM
product
WHERE
product_id = product_id_var;
IF available_units_var > 0 THEN
total_price_var := ( total_price_var + curr_price_var );
total_qty_var := total_qty_var + 1;
INSERT INTO order_product VALUES (
order_id,
product_id_var
);
END IF;
-- DELETE FROM product_shoppingcart
-- WHERE product_id = product_id_var AND buyer_id = buyer_id_var;
END LOOP;
CLOSE products_cur;
SELECT
is_prime
INTO is_prime_var
FROM
buyer
WHERE
buyer_id = buyer_id_var;
IF is_prime_var = 1 THEN
shipping_price_var := 0;
END IF;
SELECT
card_id
INTO card_id_var
FROM
card_info
WHERE
buyer_id = buyer_id_var
AND is_default = 1;
SELECT
address_id
INTO address_id_var
FROM
contact_detail
WHERE
user_id = buyer_id_var
AND is_default = 1;
total_price_var := total_price_var + shipping_price_var + 10;
INSERT INTO amz_order VALUES (
order_id,
buyer_id_var,
card_id_var,
total_price_var,
sysdate,
10,
shipping_price_var,
address_id_var,
add_months(DATE '2019-11-28', 1),
'c',
total_qty_var
);
END place_order;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE populate_product_categories AS
BEGIN
INSERT INTO category VALUES (
1,
'Electronics'
);
INSERT INTO category VALUES (
2,
'Books'
);
INSERT INTO category VALUES (
3,
'Clothing'
);
END populate_product_categories;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE populate_carriers AS
BEGIN
INSERT INTO carrier VALUES (
1,
'DHL',
1234567890,
);
INSERT INTO carrier VALUES (
2,
'Fedex',
1234567890,
);
INSERT INTO carrier VALUES (
3,
'UPS',
1234567890,
);
END populate_carriers;
--------------------------------------------------------------------------------------------
CREATE OR REPLACE TRIGGER update_available_units AFTER
INSERT ON amz_order
FOR EACH ROW
DECLARE
product_id_var INTEGER;
available_units_var INTEGER;
CURSOR products_cur IS
SELECT
product_id
FROM
order_product
WHERE
order_id = :new.order_id;
BEGIN
OPEN products_cur;
LOOP
FETCH products_cur INTO product_id_var;
EXIT WHEN products_cur%notfound;
SELECT
available_units
INTO available_units_var
FROM
product
WHERE
product_id = product_id_var;
IF available_units_var >= 2 THEN
UPDATE product
SET
available_units = available_units - 1
WHERE
product_id = product_id_var;
ELSIF available_units_var = 1 THEN
UPDATE product
SET
available_units = available_units - 1,
in_stock = 0
WHERE
product_id = product_id_var;
END IF;
END LOOP;
CLOSE products_cur;
END;
CREATE OR REPLACE TRIGGER remove_items_from_cart AFTER
INSERT ON amz_order
FOR EACH ROW
DECLARE BEGIN
DELETE FROM shopping_cart
WHERE
buyer_id = :new.buyer_id;
DELETE FROM product_shoppingcart
WHERE
buyer_id = :new.buyer_id;
END;
BEGIN
register_buyer('[email protected]', 'anshul', 'pardhi', 'abcd123');
register_buyer('[email protected]', 'ashwani', 'kashyap', 'abcd123');
register_buyer('[email protected]', 'gunjan', 'agicha', 'abcd123');
END;
BEGIN
register_seller('[email protected]', 'kushagra', 'dar', 'abcd123', 'kushagra Co and Co',
'www.kusharga.com', 'company of shoes');
register_seller('[email protected]', 'ruchi', 'singh', 'abcd123', 'ruchi Co and Co',
'www.ruchi.com', 'company of metals');
register_seller('[email protected]', 'anant', 'prakash', 'abcd123', 'anant Co and Co',
'www.anant.com', 'company of iphones');
END;
BEGIN
update_contact_details('[email protected]', 1, '7825 McCallum Blvd', 'Apt 007', 'Dallas',
'Texas', 'USA', 75252, 8888888888);
update_contact_details('[email protected]', 2, '7825 McCallum Blvd', 'Apt 1702', 'Dallas',
'Texas', 'USA', 75252, 8888888888);
update_contact_details('[email protected]', 3, '7825 McCallum Blvd', 'Apt 1702', 'Dallas',
'Texas', 'USA', 75252, 4692309274);
set_default_contact_details(3, '[email protected]');
set_default_contact_details(1, '[email protected]');
END;
BEGIN
add_card_info('[email protected]', 1, 1234123412341234, TO_DATE('2023-12-09', 'YYYY-MM-DD'),
666);
add_card_info('[email protected]', 2, 0234123412341234, TO_DATE('2023-12-09', 'YYYY-MM-DD'),
777);
add_card_info('[email protected]', 3, 0234123412341234, TO_DATE('2023-12-09', 'YYYY-MM-DD'),
777);
set_default_card_info(1, '[email protected]');
set_default_card_info(3, '[email protected]');
END;
BEGIN
populate_product_categories();
populate_carriers();
END;
BEGIN
add_product(1, 'OnePlus 7', '[email protected]', 400, 1,
'Best Phone', 2, 'Blue', 2, 2,
'bit.ly/sfdf4fg');
add_product(2, 'Harry Potter', '[email protected]', 15, 2,
'Best Book', 5, 'Black', 8, 2,
'bit.ly/sfdf4fg');
add_product(3, 'Nike Shoes', '[email protected]', 50, 3,
'Best shoes', 2, 'yellow', 5, 1,
'bit.ly/sfdf4fg');
add_product(4, 'I phone', '[email protected]', 500, 1,
'Better than android', 3, 'Black', 2, 3,
'bit.ly/sfdf4fg');
add_product(5, 'Metal Detector', '[email protected]', 20, 1,
'Best metal detector', 4, 'Grey', 12, 2,
'bit.ly/sfdf4fg');
END;
BEGIN
add_to_wish_list('[email protected]', 1);
add_to_wish_list('[email protected]', 4);
add_to_wish_list('[email protected]', 3);
add_to_wish_list('[email protected]', 2);
END;
BEGIN
add_to_shopping_cart('[email protected]', 1);
add_to_shopping_cart('[email protected]', 3);
add_to_shopping_cart('[email protected]', 2);
add_to_shopping_cart('[email protected]', 1);
END;
BEGIN
update_membership('[email protected]');
END;
BEGIN
place_order(1, '[email protected]');
END;
BEGIN
place_order(2, '[email protected]');
END;
BEGIN
give_review(1, 1, '[email protected]', 'cool phone with great camera', 5,
'www.my_image.com');
give_review(2, 3, '[email protected]', 'good running shoes', 3,
'www.my_image.com');
END;
BEGIN
give_review(3, 2, '[email protected]', 'nice book', 3.5,
'www.my_image.com');
END;
BEGIN
give_review(4, 1, '[email protected]', 'okay phone', 3,
'www.my_image.com');
END;
BEGIN
give_review(5, 5, '[email protected]', 'doesnt work', 1,
'www.my_image.com');
END;
BEGIN
give_review(6, 5, '[email protected]', 'doesnt work at all', 0,
'www.my_image.com');
END;