Database Management System Lab Assignments
1. Create the following tables:
a) Table Name : DEPT(representing Department)
Column Name Data Type Size Constraints
D no Number 3 Primary key
D name Varchar 10
b) Table Name : EMP (representing Employee)
Column Name Data Type Size Constraints
E no Varchar 5 Primary key and first character must be ‘E’
E name Varchar 10 Not null
City Char 10 Cities allowed
‘delhi’, ’kolkata’, ’chennai’, ’mumbai’
Salary Integer
Join Date Date
D no Number 3 Foreign key reference DEPT table
c) Table Name : PROJECT (representing Project)
Column Name Data Type Size Constraints
P no Varchar 5 Primary key and first character must be ‘P’
E no Varchar 5 Primary key and foreign key reference
EMP
2. Insert the following data into the corresponding table:
a) Table:DEPT
Dno Dname
1 research
2 finance
b) Table:EMP
Eno Ename City Salary JoinDate Dno
E1 ashim kolkata 18000 01-jan-14 1
E2 kamal mumbai 10000 01-jun-14 2
E3 tamal chennai 7000 01-jan-15 1
E4 asha kolkata 8000 01-jun-15 2
E5 timir delhi 7000 01-jan-16 1
c) Table:PROJECT
Pno Eno
P1 E1
P2 E3
P1 E5
P2 E1
3. Write SQL for following queries:
a) Display the structure of table EMP.
b) Modify the data type size of Ename to varchar15.
c) Display the user constraints of table EMP.
4. a) Add a new column Mobile no which is unique (candidate key) of table EMP.
b) AddtheconstraintforMobilenowhichisexactlyof10digit.
c) Drop all constraints of Mobile no.
d) Drop the column Mobile no of table EMP.
5. a) Add a new column MgrId (representingManagerId) of data size number5 and
MgrId values should reference from Eno of table EMP.
b)Update the table EMP with following MgrId values:
Eno Ename City Salary JoinDate Dno Mobileno MgrId
E1 ashim kolkata 18000 01-jan-14 1 9876543211 E1
E2 kamal mumbai 10000 01-jun-14 2 9876543212 E2
E3 tamal chennai 7000 01-jan-15 1 9876543213 E1
E4 asha kolkata 8000 01-jun-15 2 9876543214 E2
E5 timir delhi 7000 01-jan-16 1 9876543215 E1
6. a) Display list of all employees in department no2.
b) Display name and salary of employees in department number1 and 2.
c) Display name of employees having ‘a’ as the second letter in their name.
d) Display list of all employees who have named exactly 4 characters.
e) Display employee names and department no for those who joined in the month of June.
f) Display the list of all employees who were joined during 2025.
g) Display the joining date of all employees in dd/mm/yy format.
7. a) Display names of all employees in the alphabetic order.
b) List the name and the salary of all employees ordered by salary descending order.
c) List all the employee names whose salary is greater than 7000 and less than 18000.
d) List of all employees who have salary between 7000 and 8000.
e) Display employee names and department nos of all employees who belong to either
‘chennai’, or ‘kolkata’, or ‘mumbai’.
8. a) Find the average salary of all employees.
b) Find the difference between highest and lowest salary of employee.
c) Display the department no and no. of employees in each department.
d) Display employee no, employee name and salary for employee with lowest salary.
e) List only the names of all other employees who get the same salary as that of ‘tamal’.
9. a) Find all department numbers that have more than two employees.
b) Display the names of all employees who engaged in two or more projects.
c) List no. of projects undertaken in the department1.
d) Display name and salary for all employees who are engaged with at least one project.
e) Display employee names and department names of all employees who belong to either
‘chennai’, or ‘kolkata’, or ‘mumbai’.
10. a) Display employee name who get the highest salary.
b) Display employee name who get the 2ndhighest salary.
c) Display department number having most number of employees.
d) Display employee name along with their manager name using self-join concept.
e) Display employee name along with their department name using natural join and inner
join.
f) Display student roll no, sname, company cname, campus cdate where they got job using
left, right and full outer join on student and placement table having common attribute roll
no.
11. a) Display name of employees whose either salary>=8000 or resides in city Kolkata
using union operation.
b) Display name of employees whose salary>=8000 and resides in city Kolkata using
intersect operation.
c) Display employees name, salary and city whose salary>=8000 but not resides in city
Kolkata using minus operation.
d) Display detail of employees who work in some project.
e) Display detail of employees who does not work in any project.