-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathpostgresquery.txt
19 lines (14 loc) · 1.29 KB
/
postgresquery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
create table Category (Item_Code int, Item_Name varchar(50), Unit_Price int, Quantity int, Constraint Item_Code_Pk Primary Key(Item_code));
create table FoodItems (DOM Date, DOE Date,Vegetarian bit, Item_Code_Ref int, Constraint FoodItem_Fk Foreign Key(Item_Code_Ref) References Category(Item_code));
create table Apparel(Size int, Material int, Item_Code_Ref int, ConstraintApparel_Fk Foreign Key(Item_Code_Ref) References Category(Item_code));
create table Electronics(Warranty int, Item_Code_Ref int, Constraint Electronics_Fk Foreign Key(Item_Code_Ref) References Category(Item_code));
addproduct=insert into ADMIN.PRODUCT(ITEM_CODE,NAME,QTY,UNIT_PRICE)values(?,?,?,?)
addfooditems=insert into ADMIN.FOOD_ITEMS(ITEM_CODE,VEGETERIAN,DOE,DOM)values(?,?,?,?)
addelectronics=insert into ADMIN.ELECTRONICS(ITEM_CODE,WARRANTY)values(?,?)
addapparel=insert into ADMIN.APPAREL(ITEM_CODE,MATERIAL_TYPE,SIZE)values(?,?,?)
selectfooditems=select p.ITEM_CODE,p.NAME,p.QTY,f.VEGETERIAN from ADMIN.PRODUCT p, ADMIN.FOOD_ITEMS f
where p.ITEM_CODE=f.ITEM_CODE
selectapparel=select p.ITEM_CODE,p.NAME,p.QTY,a.SIZE,a.MATERIAL_TYPE from ADMIN.PRODUCT p, ADMIN.APPAREL a
where p.ITEM_CODE=a.ITEM_CODE
selectelectronics=select p.ITEM_CODE,p.NAME,p.QTY,e.WARRANTY from ADMIN.PRODUCT p, ADMIN.ELECTRONICS e
where p.ITEM_CODE=e.ITEM_CODE