Vous êtes sur la page 1sur 12

Assignment No.

03
SEMESTER Fall 2019 Total Marks: 20

CS403- Database Management System

Due Date: January 20,


2020

1. Convert the above relational data model into a physical database. For which you have to first create a
database. So, write a SQL statement which creates a database. The database name should be as your
student id. For example, if your student id is BC123456789, then the database name should also be
BC123456789.
*If database name is different from your student id, then your assignment will be graded as zero.

2. After the database creation, you are required to write the SQL queries in order to create all tables in the
database. You also have to apply different constraints like primary key constraint and foreign key
constraints where applicable.
3. After creation of all tables, you are required to add the following records into the Order, Customer and
Bill tables by writing the appropriate SQL Queries.

Order Table:

Order_ID Order_Status Delivery_Date Manager_ID Customer_ID Sman_ID

od001 Completed 01/01/2020 mg001 cust001 sm001

od002 Completed 05/01/2020 mg002 cust002 sm001

od003 Pending null mg003 cust001 sm001


Customer Table:
Customer_ID Name Address Contact_no email

M.A Jinnah Campus, Defence


cust001 Customer 01 Road,Off Raiwind Road, Lahore 3001234567 cust001@domain.com

M.A Jinnah Campus, Defence


cust002 Customer 02 Road,Off Raiwind Road, Lahore 3001234567 cust002@domain.com

M.A Jinnah Campus, Defence


cust003 Customer 03 Road,Off Raiwind Road, Lahore 3001234567 cust003@domain.com

Bill Table:
Bill_ID Order_ID date Amount

b001 od001 01/01/2020 500

b002 od002 05/01/2020 550

b003 od003 09/01/2020 500


4. Write a query that retrieves all records from the Ordertable where Order_Status is “Pending”.

5. Finally retrive the “Completed Orders” in a inner joined table such as:
 Order_ID as OID from order table
 Order_Status as Status from order table
 Delivery_Date as Date from order table
 Customer_name as Name from customer table
 Amount as Bill Amount from Bill table

The expected outcome of the query is given bellow:


OID Status Name Date Bill Amount

od001 compeleted Customer 01 01/01/2020 500

od002 compeleted Customer 02 05/01/2020 550

Vous aimerez peut-être aussi