0% found this document useful (0 votes)
3 views

Assignment3 2021

Uploaded by

Sandun Sanjeewa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment3 2021

Uploaded by

Sandun Sanjeewa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

BCS General Degree – Level 1

CSC1213 - Database Management Systems (DBMS)


Practical Assignment - 3

DBMS with SQL using MySQL Server


One sales electric and electronic products with the branches located in various districts. They maintain 3
separate data sheets to keep their company details as follows.
Item datasheet - Details of electric and electronic products
Store datasheet - Details of stored quantities in their branches
Location datasheet - Details of the branches
Based on this case, develop the company database in MySQL and practice the questions in your
assignment.

1. Log on to the MySQL server.

2. Create a blank database as “elec”.

3. Active your database as the current working database.

4. Create table called “item” using the following structure.

Description of the Table structure


Field Name Data Type Length
item_code Char 4
It_description Varchar 25
It_unit_price Decimal (9,2)
It_imported Tinyint 1
It_supplier Text 20

5. Add following records to above table.


item_code description unit_price imported supplier
IT10 Television 24000.00 1 Sony
IT11 Computer 60000.00 1 Dell
IT12 Laser Printer 19000.00 1 HP
IT13 VCD Player 7599.00 1
IT15 Polisher 12000.00 1 National
IT16 Scanner 16000.00 HP
IT17 Refrigerator 65000.00 1 LG
IT18 Table Lamp 2999.90 0 Abans
IT19 Wall Clock 1200.00 1
IT20 Blender 4800.00 1 National
IT14 Oven 7300.00 0 Abans

6. Create the following table structure called location

Field Name Data Type Length


lo_code char 4
lo_name varchar 25
lo_contact char 11
Lo_address Text 300

2020 - Department of Computer Science, University of Ruhuna, Matara, Sri Lanka. 1


7. Enter following data into location table.

code locationName contact address


L01 Colombo 0112946058 Colombo 04
L02 Kalutara Main Street
L03 Galle 0912546893
L04 Matara 0415670045 Dharmapala Mawatha

8. Observe the following data set and create a suitable table structure called store to add following
record to the same table.

item_code location_code qty date


IT10 L01 30 2020-04-08
IT10 L03 3 2020-04-02
IT10 L04 10 2020-04-25
IT11 L01 25
IT11 L02 12 2020-05-07
IT13 L04 60 2020-05-09
IT16 L02 5

Write following Queries using SQL statements

1. Find out the names of the tables you have created in your database.

2. Examine the structure of the table item.

3. Exit from MySQL server and log on again.

4. Retrieve all records from item table.

5. Retrieve all records from location table.

6. Retrieve all records from store table.

7. Retrieve description and unit_price from Item table

8. Retrieve the item codes from store table.

9. Retrieve the item codes without repetition from store table.

10. Retrieve description and unit_price from Item table according to the descending order of the unit
price.

11. Retrieve sitem_code and st_qty from the store table according to the ascending order of
item_code and then by descending order of qty.

2020 - Department of Computer Science, University of Ruhuna, Matara, Sri Lanka. 2


12. Retrieve all records from Item table where unit_price is greater than 20000.00.

13. Retrieve item codes which are stored in the location L01.

14. List the item descriptions begin with letter T.

15. List the item descriptions end with er.

16. List the details of items of supplier Dell, HP and LG

17. Get the item code and the item name which supplier is known.

18. Get the item code and the item name which supplier is not known.

19. Retrieve description, stored quantity and location name where items unit_price exceeds 20000.00.

20. Retrieve item_code, locationName and qty for the items which are stored in store table.

21. Retrieve the Item descriptions and stored location names.

22. How many items are available in the item table?

23. Get the summation of quantities stored in all locations.

2020 - Department of Computer Science, University of Ruhuna, Matara, Sri Lanka. 3

You might also like