SILIGURI INSTITUTE OF TECHNOLOGY
DATABASE MANAGEMENT SYSTEM LAB (PCC CS - 691)
NAME………………………………………………………………………………………………………………………………………………..
DEPARTMENT……………………………………………………………………………………………….. SECTION…………………
YEAR……………………………………………………………………... SEMESTER……………………………………………………...
UNIVERSITY ROLL NO………………………………………………………………………………………………………………………
UNIVERSITY REGISTRATION NO…………………………………………………………………………………………...………….
INDEX
ASSIGNMENT 1
EXp. DATE OF DATE OF REPORT GRADE / TEACHER’S
Day NAME OF THE EXPERIMENT
NO. EXP. SUBMISSION REMARKS SIGNATURE
a)Create following tables–
Table Name: Department
Col Name Type Width Constraint
DNO NUMBER 2 PRIMARY KEY
DNAME VARCHAR2 10 NOT NULL
Table Name: Employee
Col Name Type Width Constraint
ENO NUMBER 2 PRIMARY KEY
ENAME VARCHAR2 10 NOT NULL
DNO NUMBER 2 REFERENCES Dept
SALARY NUMBER 6
b) Insert the following data–
Table: Department
DNO DNAME
10 Admin
20 Accounts
30 Sales
40 Marketing
1 1 50 Purchasing
Table: Employee
ENO ENAME DNO SALARY
1 Amal 10 30000
2 Shyamal 30 50000
3 Kamal 40 10000
4 Nirmal 50 60000
5 Bimal 20 40000
6 Parimal 10 20000
c) Display all data from Department table.
d) Display all data from Employee table.
e) Try to insert following value
(1,’akash’,60,70000)
f) Try to insert following value
(7,’akash’,60,70000)
g)Display name and salary of all employees whose
department no is 10.
h) Display the name and salary of all employees
who working in Accounts Department.
I) Create a table BackUp (Ename, Dname) and
copy data from above tables.
DATABASE MANAGEMENT SYSTEM LAB
INDEX ( CONTINUE….)
EXP. DATE OF REPORT GRADE / TEACHER’S
Day NAME OF THE EXPERIMENT DATE OF EXP.
NO. SUBMISSION REMARKS SIGNATURE
a)Create following tables–
Table Name: Project
Col Name Type Width Constraint
PNO NUMBER 2
PNAME VARCHAR2 10
LOCATION VARCHAR2 20
Table Name: Work
Col Name Type Width Constraint
ENO NUMBER 2 REFERENCES Employee
PNO NUMBER 2
HOURS NUMBER 3
PLOCATION VARCHAR2 20
b) Add a foreign key constraint on column
‘PNO’ in ‘Work’ table referencing column
‘PNO’ in table ‘Project’ and name the
constraint as FK_PNO. ( Copy the Error
message)
c) Add a Primary Key on PNO in Project Table.
d) Add a Primary Key on Eno in Work Table.
2 1 e) Drop the Primary Key of the table Work.
f) Now add a composite Primary key on
ENO,PNO in Work Table.
g) Try to add a foreign key constraint on
column ‘PNO’ in ‘Work’ table referencing
column ‘PNO’ in table ‘Project’ and name the
constraint as FK_PNO.
h) Add a check constraint on ‘LOCATION’
column so that permissible value for
‘LOCATION’ attribute must be among
‘Kolkata’, ‘Mumbai’, ’Chennai’, ’Delhi’ and
name the constraint as CHK_LOC.
i) Add a new column ‘MANAGER_No’ in table
‘Employee’. The data type is number and
width is 3.
j) Change width of ‘MANAGER_NO’ column to
2.
k) Add a NOT NULL constraint on Pname in
Project Table.
l) Drop column PLOCATION from Work Table.
m) Rename column HOURS to WORKING_HRS
in Work Table.
DATABASE MANAGEMENT SYSTEM LAB
INDEX ( CONTINUE….)
EXP. DATE OF DATE OF REPORT GRADE / TEACHER’S
Day NAME OF THE EXPERIMENT
NO. EXP. SUBMISSION REMARKS SIGNATURE
Insert appropriate data on Project table and
1 Work table.
Update MANAGER_NO column with following
data:-
ENO MANAGER_NO
1
2 2 1
3 4
4 5
5 2
6 1
Write queries using SQL:-
a. To list the name and from the Employee.
b. Display data from table ‘Project’ with column
heading PROJECT_NO, PROJECT_NAME.
c.Display the name, salary, HRA of employees
(HRA calculated as 15% of salary).
3 d. List the name of the Project in Mumbai.
e.List employees having name starting with
letter ‘S’.
f. List Employees where second character of
name is ‘a’.
g. To list the Project name where the project
3
locations are Kolkata or Delhi.
h. List the name of all employees from where
department no is 10 and salary above 50000.
i. To sort the employee data in alphabetic order
of employee name.
j. To sort the employee data in descending
order of salary.
k. To evaluate the working hour of an
employee. If employee work more than 30
hours then display ‘more than 30 hrs’, if equal
to 30 then display ‘exact 30’ otherwise display
‘below 30’.
Write queries using SQL:-
a. Display the employee name, department
name and project location of all employee.
b. Display the employee name, project name,
working hour of all employee.
c. Display names of all employees who work
more than 28 hours.
d. Display the name of all employees who work
in ‘Kolkata’ or ‘Mumbai’.
e. Display name of the employee, who work in
4 4 same location as that of ‘Shyamal’.
f. List the name of employees who are working
on more than one project.
g. Write a query to select first two rows from
employee table.
h. Write a query to select last two rows from
employee table.
i. Retrieve the maximum and minimum salary
for each department.
j. Display the employee name and their
respective manager’s name.
DATABASE MANAGEMENT SYSTEM LAB
INDEX ( CONTINUE….)
EXP. DATE OF REPORT GRADE / TEACHER’S
Day NAME OF THE EXPERIMENT DATE OF EXP.
NO. SUBMISSION REMARKS SIGNATURE
k. Display the name of the employee who is
earning second maximum salary.
l. Display the name of the employee who is
earning nth highest salary.
m. Display the name of the employees whose
salary is greater than the salary of all the
employee whose manager no is 2.
n. Get the details of all employees whose
salary is lesser than the average salary of the
employees.
o.Drop the primary key from Work table.
p. Insert two duplicate row in work table.
q. Delete duplicate rows from work table.
r. Create a view that will show department
name and total salary. The name of view will
be account.
s. Select the department names having total
salary greater than 45000.
i) Using result view
ii) Using student table.
t. Write a query to retrieve Employee names
from the Employee table and output will look
like:-Mr. A
Create following tables:-
HOTEL (HOTEL_NO, NAME, ADDRESS )
ROOM( ROOM_NO, HOTEL_NO, TYPE, PRICE)
BOOKING(HOTEL_NO, GUEST_NO,
DATE_FROM, DATE_TO, ROOM_NO)
GUEST(GUEST_NO, NAME, ADDRESS)
Where HOTEL contains hotel details and
HOTEL_NO is the Primary Key. ROOM
1 contains room details for each hotel and
(HOTEL_NO,ROOM_NO) forms the Primary
key. BOOKING contains details of the
bookings and the Primary Key comprises
(HOTEL_NO, GUEST_NO, DATE_FORM) and
GUEST contains guest details and GUEST_NO
is the Primary key and mention the Foreign
Key constraints
5 a. List full details of hotels in Mumbai
b.List the name and addresses of all guests in
New Delhi, alphabetically ordered by the
name.
c. List all double or family rooms with a price
below Rs. 800 per day, in ascending ordered.
d.List the bookings for which no date_to has
been specified.
e.What is the total daily revenue from all the
2 double room?
f.How many different guests have made
booking for august, 2024.
g.List the price and type of all rooms at the
hotel Land Mark.
h. What is the total income from booking for
the hotel Manor.
i.Retrieve the Hotel name where double
room price is above 5000 and single room
DATABASE MANAGEMENT SYSTEM LAB
price is below 2500.
j. Drop table Booking.
l. Truncate table Room.
m.Describe and Select Room table.
DATABASE MANAGEMENT SYSTEM LAB
ASSIGNMENT 2
EXP. DATE OF REPORT GRADE / TEACHER’S
Day NAME OF THE EXPERIMENT DATE OF EXP.
NO. SUBMISSION REMARKS SIGNATURE
Write a PL/SQL program to check the
1 given number is even or odd.
Write a program to check whether a given
2 number is prime or not.
6 Write a PL/SQL program to check whether a
3 number is Armstrong number or not.
Write a program to calculate the net salary of
4 a employee where DA is 50%, HRA is 15% of
salary. (use previous Employee table.).
a) Wria) Write a PL/SQL code block to calculate the
area of a circle for a value of radius varying
from 3 to 7. Store the radius and the
corresponding values of calculated areas in
table.
b) Add an extra column diameter to the table
circle and update the diameter column for
each entry diameter=2* radius.
c) Print the number of records in the circle
table with the help of an explicit cursor.
A HRD manager has decided to raise the
salary for all the employees in department
number 10 by 0.05, department number 20
by 0.08, department number 30 by 0.1 and
other department by .03 . Whenever any
such raise is given to employees an audit trail
of the same is maintained in the EMP_RAISE
table. The EMP_RAISE table holds the
7 1 employee number, the date when the raise
was given and the raise amount.
Write a PL/SQL block to update the salary of
each employee appropriately and insert a
record in the EMP_RAISE table as well.
Tables are as follows:
EMP_RAISE(EMP_CODE, RAISE_AMOUNT,
RAISE_DATE)
Write a PL/SQL function, which returns
1 maximum of the three numbers.
Write a function, which returns net salary
of a given employee where DA is 50%, HRA
2 is 15% of salary. (use previous Employee
table.). If employee No is not found then
8 return False.
Write a procedure to calculate sum of two
3 numbers.
Write a procedure, which returns net salary
and department of a given employee where
4 DA is 50%, HRA is 15% of salary. (use
previous Employee table.)
DATABASE MANAGEMENT SYSTEM LAB
Create a transparent audit system for a
table Employee. The system must keep
track of the records that are being
deleted or updated. The functionality
being when a record is deleted or
modified the original record details and
9 1 the date of operations is stored in the
audit-client table, the delete or update
is allowed to go through.
Write a trigger for the above problem.
The Tables are as follows:-
AUDIT (EMP_NO, NAME, DEPT_NO,
OPERATION,USER_ID,OP_DATE)
DATABASE MANAGEMENT SYSTEM LAB
ASSIGNMENT 3
DATE OF
EXP. DATE OF GRADE / TEACHER’S
Day NAME OF THE EXPERIMENT REPORT
NO. EXP. REMARKS SIGNATURE
SUBMISSION
Create a user with following characteristics
i. Set password
ii. Limits on database resources
defined by the profile DEFAULT
a.Grant the role Connect to the user with
admin option.
b. Grant Resource and other necessary
1
system privileges to this user. (e.g. Alter,
Create, Insert, Delete, Grant etc.)
c.After successfully creating this user, try to
connect using this username and password.
d. Now Create the Table Employee(Eno
Number(2), EName Varchar2(15)).
e. Insert 3 records.
2 Create a Unique Index on column Eno in
Employee table.
DATABASE MANAGEMENT SYSTEM LAB
Department of Information Technology
Database Management System (PCC CS 691)
Laboratory Assignment Rubric
Experiment Date:- Submission Date:-
Day:-
Criteria & Point
Outstanding Excellent Average Below Average
Assigned
Marks
Content 4 3 1 0
All Major
steps/programs steps/programs
Experimental Some major Wrong
are completely are completely
procedure errors. attempt.
correct and correct and
accurate. minor mistake.
All programs are Some programs Major errors in
Capability of writing Programs are
written precisely are written program writing.
Program not written.
properly. accurately.
Output are correct
Output are Wrong
and well Output are
Result or Output correct output/no
formatted partially correct
output found.
Completion of
100% 75% 50% 25%
Target
Proper Time i.e. in Submission of
All experiments
next day Lab., Lab Fair Copy in
that have been
Submission of Lab with properly proper time but Late
completed last
Copy written Exp. Date, not found Exp. Submission.
day lab. , not
Exp. No. and Exp. Date, Exp. No.
found.
Name. and Exp. Name.
Total Marks with Grade
Between 20 – 16 ----> A (5)
Between 15 – 11 ----> B (4)
Marks Evaluation
Between 10 – 06 ----> C (2)
Between 05 – 00 ----> D(0)
Signature of the Examiner with Date
DATABASE MANAGEMENT SYSTEM LAB