Assignment 5 (2)
Assignment 5 (2)
Based on School_Items database , practice the following the questions in your assignment.
Relevant data tables in the School_Items database as follows.
item bookShop
itCode itName price imported brand bsCode bsName contact address
IT10 Stapler 240.00 1 Mango BS01 Sarasavi 0112946058 Colombo 04
IT11 Pen 60.00 0 Atlas
BS02 Godage NULL Main Street
IT12 Pencil 40.00 0 Atlas
BS03 Gunasena 0912546893 NULL
IT13 Eraser 20.00 0 NULL
IT15 Backpack 4000.00 0 DSI BS04 Samudra 0415670045 Dharmapala Mawatha
IT16 Notebook 160.00 NULL Atlas
IT17 Folder 20.00 1 Mango distribute
IT18 Calculator 2700.00 1 Casio itCode bsCode qty date
IT19 Highlighter 150.00 0 NULL IT10 BS01 30 2023-04-08
IT20 Scissors 100.00 0 Mango IT10 BS03 3 2023-04-02
IT14 Flash Drive 1500.00 1 Kingston IT10 BS04 10 2023-04-25
IT11 BS01 25 NULL
IT11 BS02 12 2023-05-07
sales
IT13 BS04 60 2023-05-09
billNo itCode bsCode salesQty salesDate cuCode
IT16 BS02 5 NULL
B1 IT10 BS01 3 2023-6-2 C01
B2 IT10 BS03 1 2023-6-12 C03
customer
B3 IT13 BS04 15 2023-5-7 C02 cuCode name address
B4 IT11 BS01 12 2023-6-15 C01 C01 Thisath Matara
B5 IT11 BS02 5 2023-5-12 C01 C02 Nipuna Colombo
C03 Samadi Kandy
1. Find out the names of the databases created in your MySQL server.
2. Find out the names of the tables you have created in your database.
6. Create the following table called customer and enter the details of customers. (cuCode should be
the primary key of the table)
7. Add a new field called cuCode to the sales table to enter the customer code.
8. Examine the structure of the table sales.
9. Update the cusCode field of sales table according to the bill numbers of following table.
billNo cuCode
B1 C01
B4 C01
B5 C01
B2 C03
B3 C02
10. Increase the length of the bsName in the bookShop table, upto varchar(30)
11. Find the most recent sales date available in the sales table
12. Retrieve itName and price of items which are stored at the bsCode of BS01 or BS02 according to
the descending order of the price.
13. Retrieve itName, price and bsCode of items which are distributed by the company with bsCodes
of BS01 or BS02 according to the descending order of the bsCode.
15. Get the total quantity of all items distributed by the Sarasavi bookshop.
17. Find the names of the item which has the largest price.
18. One customer is going to by 10 pens with 10% discount. How many rupees have to be paid by the
customer for this deal?
19. Increase the unit prices by 5.00 rupees for the Pens and Steplers.
20. Get the item code and the item name which brand is known.
21. Using the distribute table, retrieve the total distributed quantity for each item category. (Display
the item code vs total quantity for each item category)
22. List the item name and the total quantity for each item name which distributed by all bookShops.
(Display the item name vs total quantity for each item name).