Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Reg#:______________________ Name: _____________________________ Section: ______

Deadline: 13/6/2024

Consider the given database schema and perform the given task.
Employee ASG
ENO ENAME TITLE ENO PNO RESP DUR
E1 ASLAM Elect. Eng. E1 P1 Manager 12
E2 KAMRAN Syst. Anal. E2 P1 Analyst 24
E3 IRFAN Mech. Eng. E2 P2 Analyst 6
E4 USMAN Programmer E3 P3 Consultant 10
E5 AWAIS Syst. Anal. E3 P4 Engineer 48
E6 MUZAMIAL Elect. Eng. E4 P2 Programmer 18
E7 IFFAT Mech. Eng. E5 P2 Manager 24
E6 P4 Manager 48
E8 SAIMA Syst. Anal E7 P3 Engineer 36
E8 P3 Manager 40

Project Pay
PNO PNAME BUDGET CITY TITLE SAL
P1 NADRA 150000 RWP Elect Eng. 40000
P2 Database Develop. 135000 KHI Syst. Anal. 34000
P3 CAD/CAM 250000 LHR Mech. Eng. 27000
P4 Maintenance 310000 MUL Programmer 24000

Write down the SQL queries for following by using schema given in Question 1. Assume appropriate data
types for each attribute by yourself.

Note: ENO and PNO of ASG comes from Employee and Project respectively
1) Create ASG table
2) Assume you forget to made ENO as Primary key during creation of Employee table; by default, ENO is declared
as null. Now you have to declare ENO as Primary key.
3) Add constraint on name of Employee that ensures that name must start with alphabet.
4) Drop a constraint that is added in Statement 3.
5) Add a new column Hiring Date in Employee table which must store date in it.
6) Drop a column that is added in statement 5.
7) Change the data type of any one column of employee table.
8) Add a default constraint on city of Project that ensure that default value for city is ‘RWP’
9) Show data of only those Employee who are not working on any project yet.
10) Make a hybrid partition on Project table in such a way that changes on partitioned portion must not be reflected
on original table.
11) Make horizontal partition on Employee table in such a way that changes on partition portion must reflect on
original table.
12) Update the ENAME of the Employee as ‘Kashif’ whose ENO is E3.
13) Delete all those records of Project table whose Budget is above 135000.
14) Insert a record in Employee table.
15) Show data of only costly project.
Reg#:______________________ Name: _____________________________ Section: ______

16) Show data of 2nd costly project.


17) Show all those employee who are not working on any project yet.
18) Show all those project whose project duration is either 6 or 20 or 25 or 40.
19) Assume you forget to made Title as foreign key during creation of Employee table; by default, Title is declared
as null. Now you have to declare title as foreign key.
20) Show all those employee whose salary is above 40000.

You might also like