You are on page 1of 5

CAPITAL UNIVERSITY OF SCIENCE

& TECHNOLOGY, ISLAMABAD

INTRODUCTION TO DATABASE SYSTEMS LAB (CS2311)


MID-TERM EXAM FALL 2018 (A)
Usama Hassan BCS173066
Name: ________________ Reg. No: _____________ Section: _____S2_________

Total Time 90 Minutes Total Points: 40

Note:
 Read the problem carefully before writing the solution.
 Paper consists of two questions.
 Use the schema given at first page to answer first question.
 No Extra time will be provided.
 You can make my task easy by submitting after the timeline or by copying others.

1
Question 1: Use ‘classic’ database schema to write the SQL queries for
following problems. (30)

1. Show customer number, order number, and status of all orders.

mysql> select customerNumber,orderNumber,status from orders;


+----------------+-------------+---------+
| customerNumber | orderNumber | status |
+----------------+-------------+---------+
| 2| 1 | Pending |
| 3| 2 | Shipped |
| 4| 3 | Shipped |
+----------------+-------------+---------+

2. Select all employees whose Name contains two times “n”


mysql> select employeeName from employees where employeeName like 'n,n%';
Empty set (0.06 sec).

3. Change the quantityInStock to 6 where productCode is 3.

4. Show number of employees working in each office in ascending order of their


office code.

5. Show names of top 10 customers (top= credit limit)

2
6. Show customer number and Total Amount paid by each customer.

7. Which customer has placed highest number of orders?

8. Delete all payments of the year 2004.

9. Show total number of products belonging to each vendor.

3
10. Concat office code and phone of all offices.

Question 2: Dry Run the given query step by step and show resultSet at each
intermediate step. (10)
1. Create a database named as “Bookshop_db”.

2. Create a table for storing books.

Book_name varchar(120) ( Constraints : not null DEFAULT ‘No Name’)


Author_name varchar(100) ( Constraints : not null)
Price float
DateOfPublication date

4
3. Change datatype of Author_name to varchar(150) with constraints not null and
default ‘No author’.

4. Insert following records in books:

Book_name : “Introduction to management”


Price : 550.5

5. Show the structure of books table (without data).

--------------------------------------- The End ---------------------------------------

You might also like