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

Assignment3

Uploaded by

janithadilsham
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

Uploaded by

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

CSC1213 Practical Assignment 03 2023

Database Management Systems (DBMS) - SQL using MySQL Server

One company distribute school items to shops and super markets in various districts. They maintain 3
separate data sheets to keep their company details as follows.
item datasheet - Details of school items
distribute datasheet - Details of distributed item quantities in shops and super markets
bookShop datasheet - Details of the shops and supper markets
Based on this case, develop the school_items database in MySQL and practice the questions in your
assignment.

1. Log on to the MySQL server.

2. Create a blank database as “school_items”.

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
itCode Char 4
itName Varchar 25
price Decimal (9,2)
imported Tinyint 1
brand varchar 20

5. Add following records to above table.

itCode itName price imported brand


IT10 Stapler 240.00 1 Mango
IT11 Pen 60.00 0 Atlas
IT12 Pencil 40.00 0 Atlas
IT13 Eraser 20.00 0 NULL
IT15 Backpack 4000.00 0 DSI
IT16 Notebook 160.00 NULL Atlas
IT17 Folder 20.00 1 Mango
IT18 Calculator 2700.00 1 Casio
IT19 Highlighter 150.00 0 NULL
IT20 Scissors 100.00 0 Mango
IT14 Flash Drive 1500.00 1 Kingston

6. Create the following table structure called bookShop

Field Name Data Type Length


bsCode char 4
bsName varchar 25
contact char 11
address Text 50

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


7. Enter following data into bookShop table.

bsCode bsName contact address


BS01 Sarasavi 0112946058 Colombo 04
BS02 Godage NULL Main Street
BS03 Gunasena 0912546893 NULL
BS04 Samudra 0415670045 Dharmapala Mawatha

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

itCode bsCode qty date


IT10 BS01 30 2023-04-08
IT10 BS03 3 2023-04-02
IT10 BS04 10 2023-04-25
IT11 BS01 25 NULL
IT11 BS02 12 2023-05-07
IT13 BS04 60 2023-05-09
IT16 BS02 5 NULL

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 bookShop table.

6. Retrieve all records from distribute table.

7. Retrieve itName and price from Item table

8. Retrieve the item codes from distribute table.

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

10. Retrieve item name and price from Item table according to the descending order of the price.

11. Retrieve all records from Item table where price is greater than 1000.00.

12. List the details of items which brand is equal to Atlas, Mango and DSI

13. Retrieve item codes which are distributed to the bookshop BS01.

14. List the item names begin with letter F.

15. List the item names end with letter er.

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

You might also like