DBMS_Lab_Syllabus
DBMS_Lab_Syllabus
Course Objectives
1. To understand the concept of DBMS and ER Modelling.
2. To explain normalization, Query optimization and relational algebra.
3. To apply concurrency control, recovery, security and indexing for real time data.
Course Outcomes
CO-PO Mapping
Program
Outcomes
Course PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 PSO3
Outcomes
CO 1 3 2 2 2 3
CO 2 3 2 2 2 3
CO 3 3 2 3 2 3
CO 4 3 2 3 2 3
CO 5 3 2 2 2 2
CO 6 2 1 1 2 1
Average 2.8 1.8 2.1 2 2.5
List of Experiments
Experiment 1:
Title: Consider the following set of requirements for a UNIVERSITY database that is used
to keep track of students’ transcripts.
1. The university keeps track of each student’s name, student number, Social
Security number, current address and phone number, permanent address and
phone number, birth date, gender, class (freshman, sophomore, ..., graduate),
major department, minor department (if any), and degree program (B.A., B.S., ...,
Ph.D.). Some user applications need to refer to the city, state, and ZIP Code of the
student’s permanent address and to the student’s last name. Both Social Security
number and student number have unique values for each student.
Design an Entity-Relationship diagram for the mail order database and enter the design
using a data-modeling tool such as ERWin/free tool. Specify key attributes of each entity
type, and structural constraints on each relationship type. Note any unspecified
requirements and make appropriate assumptions to make the specification complete.
Experiment 2
Title. Consider the following set of requirements for a Company database that is used to
keep track of employee.
The company is organized into departments. Each department has a unique name, a
unique number, and a particular employee who manages the department. We keep track
of the start date when that employee began managing the department. A department may
have several locations.
a. A department controls a number of projects, each of which has a unique name,
a unique number, and a single location.
Experiment 3
TABLE 1: EMPLOYEE
[ Fname VARCHAR(15) NOT NULL,
Minit CHAR,
Lname VARCHAR(15) NOT NULL,
Ssn CHAR(9) NOT NULL,
Bdate DATE,
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
Super_ssn CHAR(9),
Dno INT NOT NULL,
PRIMARY KEY (Ssn),
FOREIGN KEY (Super_ssn) REFERENCES EMPLOYEE(Ssn),
FOREIGN KEY (Dno) REFERENCES DEPARTMENT(Dnumber)
]
TABLE 2: DEPARTMENT
[Dname VARCHAR(15) NOT NULL,
Dnumber INT NOT NULL,
Mgr_ssn CHAR(9) NOT NULL,
Mgr_start_date DATE,
PRIMARY KEY (Dnumber),
UNIQUE (Dname),
FOREIGN KEY (Mgr_ssn) REFERENCES EMPLOYEE(Ssn) );
]
TABLE 3: DEPT_LOCATIONS
( Dnumber INT NOT NULL,
Dlocation VARCHAR(15) NOT NULL,
PRIMARY KEY (Dnumber, Dlocation),
FOREIGN KEY (Dnumber) REFERENCES DEPARTMENT(Dnumber) );
TABLE 4: PROJECT
( Pname VARCHAR(15) NOT NULL,
Pnumber INT NOT NULL,
Plocation VARCHAR(15),
Dnum INT NOT NULL,
PRIMARY KEY (Pnumber),
UNIQUE (Pname),
FOREIGN KEY (Dnum) REFERENCES DEPARTMENT(Dnumber) );
TABLE 5: WORKS_ON
( Essn CHAR(9) NOT NULL,
Pno INT NOT NULL,
Hours DECIMAL(3,1) NOT NULL,
PRIMARY KEY (Essn, Pno),
FOREIGN KEY (Essn) REFERENCES EMPLOYEE(Ssn),
FOREIGN KEY (Pno) REFERENCES PROJECT(Pnumber) );
TABLE 6: DEPENDENT
( Essn CHAR(9) NOT NULL,
Dependent_name VARCHAR(15) NOT NULL,
Sex CHAR,
Bdate DATE,
Relationship VARCHAR(8),
PRIMARY KEY (Essn, Dependent_name),
FOREIGN KEY (Essn) REFERENCES EMPLOYEE(Ssn) );
DEPARTMENT
DNAME DNUMBER MGRSSN MGRSTARTDATE
Research 5 333445555 1988-05-22
Administration 4 987654321 1995-01-01
Headquarters 1 888665555 1981-06-19
EMPLOYEE
FNAME LNAME SSN BDATE ADDRESS SEX SALARY SUPERSSN DNO
1965- 731 Fondren,
John Smith 123456789 M 30000 333445555 5
01-09 Houston TX
1965- 638 Voss,
Franklin Wong 333445555 M 40000 888665555 5
12-08 Houston TX
1968- 3321 Castle,
Alicia Zelaya 999887777 F 25000 987654321 4
01-19 Spring TX
1941- 291 Berry,
Jennifer Wallace 987654321 F 43000 888665555 4
06-20 Bellaire TX
1962- 975 Fire Oak,
Ramesh Narayan 666884444 M 38000 333445555 5
09-15 Humble TX
EMPLOYEE
FNAME LNAME SSN BDATE ADDRESS SEX SALARY SUPERSSN DNO
1972- 5631 Rice,
Joyce English 453453453 F 25000 333445555 5
07-31 Houston TX
1969- 980 Dallas,
Ahmad Jabbar 987987987 M 25000 987654321 4
03-29 Houston TX
1937- 450 Stone,
James Borg 888665555 M 55000 null 1
11-10 Houston TX
PROJECT
PNAME PNUMBER PLOCATION DNUM
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
Computerization 10 Stafford 4
Reorganization 20 Houston 1
Newbenefits 30 Stafford 4
WORKS_ON
ESSN PNO HOURS
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
453453453 1 20.0
453453453 2 20.0
333445555 2 10.0
333445555 3 10.0
333445555 10 10.0
WORKS_ON
ESSN PNO HOURS
333445555 20 10.0
999887777 30 30.0
999887777 10 10.0
987987987 10 35.0
987987987 30 5.0
987654321 30 20.0
987654321 20 15.0
888665555 20 null
DEPENDENT
ESSN DEPENDENT_NAME SEX BDATE RELATIONSHIP
333445555 Alice F 1986-04-04 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
987654321 Abner M 1942-02-28 Spouse
123456789 Michael M 1988-01-04 Son
123456789 Alice F 1988-12-30 Daughter
123456789 Elizabeth F 1967-05-05 Spouse
DEPT_LOCATIONS
DNUMBER DLOCATION
1 Houston
4 Stafford
5 Bellaire
5 Houston
5 Sugarland
Experiment 4:
Title: To understand and apply the concept of Constraints.
Objective: To understand the concept of data constraints that is enforced on data being
stored in the table. Focus on Primary Key and the Foreign Key.
1. Create the tables described below:
Table name: CLIENT_MASTER
Description: used to store client information.
Column name data type Size Constraints
CLIENTNO Varchar 6 Primary key / first letter must start with
‘C’
NAME Varchar 20 Not Null
ADDRESS 1 Varchar 30
ADDRESS 2 Varchar 30
CITY Varchar 15
PINCODE Integer 8
STATE Varchar 15
BALDUE Decimal 10,2
EXPERIMENT-5
EXPERIMENT-6
Write and execute the following queries using the Relational Algebra on the
COMPANY
database schema.
1. Retrieve the names of all employees in department 5 who work more than 10 hours
2. per week on the ‘ProductX’ project.
3. List the names of all employees who have a dependent with the same first name
as
4. themselves.
5. Find the names of employees who are directly supervised by ‘Franklin Wong’.
6. Retrieve the names of employees who work on every project.
7. Retrieve the names of employees who do not work on any project.
8. Retrieve the names and addresses of all employees who work on at least one
project
9. located in Houston but whose department has no location in Houston.
10. Retrieve the last names of all department managers who have no dependents.
EXPERIMENT-7
DEPT TABLE
EXPERIMENT-8
EXPERIMENT-9
EXPERIMENT-10
Title: Create the following views in SQL on the COMPANY database schema
presented in Experiment 2.
1. A view that has the department name, manager name, and manager salary for
every department.
2. A view that has the employee name, supervisor name, and employee salary for
each employee who works in the ‘Research’ department.
3. A view that has the project name, controlling department name, number of
employees, and total hours worked per week on the project for each project.
4. A view that has the project name, controlling department name, number of
employees, and total hours worked per week on the project for each project with
more than one employee working on it.
EXPERIMENT-11
EXPERIMENT-12
Title: To understand the concepts of Sequence.
Objective: Students will be able to implement the concept of sequence.
1) Create a sequence by name EMPID_SEQ starting with value 100 with an interval
of 1.
2) Write a SQL command for finding the current and the next status of EMPID_SEQ.
3) Change the Cache value of the sequence EMPID_SEQ to 20 and maxvalue to
1000.
4) Insert values in employees table using sequences for employee_id column.
5) Drop sequence EMPID_SEQ.
6) Create a sequence called REVERSE to generate numbers in the descending order
from 10000 to 1000 with a decrement of 5.
EXPERIMENT-13
EXPERIMENT-14
EXPERIMENT-16
1) Create a row level trigger for the customers table that would fire for INSERT
or UPDATE or DELETE operations performed on the CUSTOMERS table.
This trigger will display the salary difference between the old values and
new values.
EXPERIMENT-17
Title: To understand the concepts of Trigger.
Objective: Students will be able to implement the concept of trigger.
EXPERIMENT-18
Title: To understand the concepts of NoSQL Database
Objective: Students will be able to implement the concept of NoSQL Database
MongoDB.
1. Write a MongoDB query to display all the documents in the collection hotel.
2. Write a MongoDB query to display the fields hotel_id, name, Borough and cuisine
for all the documents in the collection hotel.
3. Write a MongoDB query to display the fields hotel_id, name, Borough and cuisine,
but exclude the field _id for all the documents in the collection hotel.
4. Write a MongoDB query to display the fields hotel_id, name, Borough and zip code,
but exclude the field _id for all the documents in the collection hotel. hotel
5. Write a MongoDB query to display all the hotel which is in the Borough Bronx.
EXPERIMENT-19
Title: To understand the concepts of NoSQL Database
Objective: Students will be able to implement the concept of NoSQL Database
MongoDB.
1. Write a MongoDB query to display the next 5 hotels after skipping first 5 which are
in the Borough Bronx.
2. Write a MongoDB query to find the hotels that achieved a score, more than 80 but
less than 100.
3. Write a MongoDB query to find the hotels which locate in latitude value less than -
95.75
4. Write a MongoDB query to find the hotels that do not prepare any cuisine of
'American' and their grade score more than 70 and latitude less than -65.754168.
EXPERIMENT-20
Title: To understand the concepts of NoSQL Database
Objective: Students will be able to implement the concept of NoSQL Database
MongoDB.
1. Write a MongoDB query to arrange the name of the cuisine in ascending order and
for that same cuisine Borough should be in descending order.
2. Write a MongoDB query to know whether all the addresses contains the street or
not.
3. Write a MongoDB query which will select all documents in the hotels collection
where the coord field value is Double.
4. Write a MongoDB query which will select the hotel Id, name and grades for those
hotels which returns 0 as a remainder after dividing the score by 7.
5. Write a MongoDB query to find the hotel name, Borough, longitude and attitude
and cuisine for those hotels which contains 'mon' as three letters somewhere in its
name.
6. Write a MongoDB query to find the hotel name, Borough, longitude and latitude
and cuisine for those hotels which contain 'Mad' as first three letters of its name.
EXPERIMENT-21
Title: To understand the concepts of NoSQL Database
Objective: Students will be able to implement the concept of NoSQL Database
MongoDB.
1. Write a MongoDB query to find the hotels which do not prepare any cuisine of
'American' and achieved a score more than 70 and located in the longitude less than -
65.754168.
2. Write a MongoDB query to find the hotels which do not prepare any cuisine of
'American ' and achieved a grade point 'A' not belongs to the Borough Brooklyn. The
document must be displayed according to the cuisine in descending order.
3. Write a MongoDB query to find the hotel Id, name, Borough and cuisine for those hotels
which contain 'ces' as last three letters for its name.
4. Write a MongoDB query to find the hotel Id, name, Borough and cuisine for those
hotels which contain 'Reg' as three letters somewhere in its name.
5. Write a MongoDB query to find the hotels which belong to the Borough Bronx and
prepared either American or Chinese dish.
6. Write a MongoDB query to find the hotel Id, name, Borough and cuisine for those hotels
which belong to the Borough Staten Island or Queens or Hyatt.
7. Write a MongoDB query to find the hotel Id, name, Borough and cuisine for those hotels
which are not belonging to the Borough New Delhi or Queens or Hyatt.
8. Write a MongoDB query to find the hotel Id, name, Borough and cuisine for those hotels
which achieved a score which is not more than 10.
9. Write a MongoDB query to find the hotel Id, name, Borough and cuisine for those
hotels which prepared dish except 'American' and 'Chinees' or hotel's name begins with
letter 'Wil'.
10. Write a MongoDB query to find the hotel Id, name, and grades for those hotels which
achieved a grade of "A" and scored 11 on an ISODate "2014-08-11T00:00:00Z" among
many of survey dates.
EXPERIMENT-22
Mini Project – On SQL
EXPERIMENT-23
Mini Project- On NoSQL