Database Fundamental (TIS 1101) Tutorial 6: Buyer - ID Invoice - ID
Database Fundamental (TIS 1101) Tutorial 6: Buyer - ID Invoice - ID
Database Fundamental (TIS 1101) Tutorial 6: Buyer - ID Invoice - ID
Tutorial 6
Q1. Based on the relationship diagram below, answer the following questions:
Buyer
1
Buyer_ID
Invoice Buyer_Name
Invoice_ID Buyer_Phone
Invoice_Date ∞ Buyer_Status
Buyer_ID
Sales 1 Invoice_Qty ∞
Item_ID
Sales_ID ∞
Sales_ID
Sales_Name
Item
Sales_Phone 1
Item_ID
Item_Name
Item_Type
Item_Price
Item_Bal
Item_Details
(a) Create a new database call “Lab06” in DB2. Next create the above tables (clearly
define the primary and foreign keys).
insert into Item values (659,'LCD Monitor', 'Computer', 900.99, 50, '24 inch
Samsung');
insert into Item values (965,'Pen', 'Stationary', 1.64, 3, 'Red ink');
insert into Item values (855,'Printer', 'Computer', 300.55, 1, 'Epson super jet');
insert into Item values (698,'Fan', 'Electrical', 86.11, 4, 'Hitachi');
insert into Item values (456,'Rubber', 'Stationary', 0.63, 98, 'Faber 3cm');
insert into Item values (598,'Hardisc', 'Computer', 250.81, 2, 'Maxtor 500GB');
insert into Item values (879,'Pen Drive', 'Computer', 98.65, 78, 'MyDrive 16GB
mini version');
insert into Item values (989,'Nokia Phone', 'Electrical', 980.21, 100, 'N85 super
series');
insert into Item values (888,'Camera', 'Electrical', 1230.36, 8, 'Sony 15
Megapixel');
(c) Write the SQL statement to list buyer’s name and phone sort by buyer’s name in
ascending order.
(e) Write the SQL statement to show all sale person name and phone who issued
invoice involving item type computer in the month of December 2008.
(f) Write the SQL statement to show all item name, item price, item balance and a
new column named as total value (price * balance) of items which is not under
the category of computer.
(g) Find all buyers name whose phone number starts with 6013.