netx_iit

Oct/Nov - 2018 Practical-3

Nov 9th, 2020 (edited)
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.69 KB | None | 0 0
  1. --select :-
  2. -----------------------------------------------
  3.  
  4. CREATE TABLE category
  5. (
  6.     categoryid NUMBER(10) primary key,
  7.     categoryname VARCHAR(40),
  8.     CHECK(categoryname IN('electronics','sports','fashion and lifestyle','home and furniture'))
  9. ); 
  10.  
  11.  
  12. CREATE TABLE product1
  13. (
  14.     productid NUMBER(10) primary key,
  15.     categoryid NUMBER(10) references category(categoryid) ON DELETE cascade,
  16.     productname VARCHAR(30),
  17.     price NUMBER(10) CHECK(price>0),
  18.     discount NUMBER(10)
  19. );
  20.  
  21. CREATE TABLE auditoffer
  22. (
  23.     offerid NUMBER(10) primary key,
  24.     categoryid NUMBER(10) references category(categoryid) ON DELETE cascade,
  25.     productid NUMBER(10) references product1(productid) ON DELETE cascade,
  26.     discount NUMBER(10)
  27. );
  28.  
  29. --insert data:-
  30. -----------------------------------------------
  31.  
  32. 1.) INSERT INTO category VALUES(101,'electronics');
  33.     INSERT INTO category VALUES(102,'sports');
  34.     INSERT INTO category VALUES(103,'fashion and lifestyle');
  35.     INSERT INTO category VALUES(104,'home and furniture');
  36.    
  37. 2.) INSERT INTO product1 VALUES(1,101,'bulbs',50,0);
  38.     INSERT INTO product1 VALUES(2,102,'basket ball',300,0);
  39.     INSERT INTO product1 VALUES(3,103,'tshirt',500,0);
  40.     INSERT INTO product1 VALUES(4,104,'table',600,0);
  41.     INSERT INTO product1 VALUES(5,101,'fairy lights',200,0);
  42.     INSERT INTO product1 VALUES(6,103,'shoes',4000,0);
  43.     INSERT INTO product1 VALUES(7,104,'chair',1700,0);
  44.    
  45. 3.) INSERT INTO auditoffer VALUES(201,101,1,10);
  46.     INSERT INTO auditoffer VALUES(202,102,2,20);
  47.     INSERT INTO auditoffer VALUES(203,103,3,40);
  48.     INSERT INTO auditoffer VALUES(204,104,4,50);
  49.     INSERT INTO auditoffer VALUES(205,101,5,30);
  50.     INSERT INTO auditoffer VALUES(206,103,6,20);
  51.     INSERT INTO auditoffer VALUES(207,104,7,60);
Add Comment
Please, Sign In to add comment