Assignment DBMS

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

BABA BANDA SINGH BAHADUR ENGG COLLEGE

Department of CSE

Student Assignment

Semester: Fifth Subject: DBMS Code: BTCS501-18

Date of Issue: 4-9-2023 Submission Date: 15-11-2023

Program: B.Tech. CSE


Course: Database Management Systems; Semester: 5th
Course Code: BTCS501-18 NBA Code: ………….
CO COs(Course Outcomes): On the successful completion of course, students will be able to:
No.
1 Write relational algebra expressions for a query and optimize the developed expressions.
(K2,K3)
2 Design the database using ER method and normalization (K4)
3 Construct the SQL Queries for open source and commercial DBMS- MYSQL, Oracle and DB2.
(K3)
4 Determine the transaction atomicity, consistency, isolation and durability. (K2,K3)
5 Implement the isolation property, including locking, timestamping based on concurrency control
and serializability of schedule. (K2,K3)

1. Discuss the roles and responsibilities of a DBA.

2. Discuss the Object, Object Relational, Relational, Network and Hierarchical model.
Compare them.

3. Consider the following set of requirements for a university database that is used to keep
track of students' transcripts.

a. The university keeps track of each student's name, student number, social security
number, current address and phone, permanent address and phone, birthdate, sex, class,
major department, minor department (if any), and degree program. Both SSN and student
number have unique values for each student.

b. Each department is described by a name, department code, office number, office


phone, and college. Both name and code have unique values for each department.
c. Each course has a course name, description, course number, number of semester
hours, level, and offering department. The value of the course number is unique for each
course.

d. Each section has an instructor, semester, year, course, and section number. The
section number distinguishes sections of the same course that are taught during the
semester/year; its values are 1, 2, 3,...upto the number of sections taught during each
semester.

e. A grade report has a student, section, letter grade, and numeric grade.

Design an ER schema for this application, and draw an ER diagram for the schema.
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.

4. Consider the following tables:


WORKS (Pname, Cname, Salary)

LIVES (Pname, Street, City)

LOCATED_IN ( Cname, City)

MANAGER (Pname, Mgrname)

Where Pname = Person name, Cname = Company name and Mgrname = Manager name.

Write the SQL Query for the following:

i. List the names of people who work for the company wipro along with cities they live
in.
ii. Find the people who work for the company infosys with a salary more than 50,000. List
the names of the people along with city and street address.
iii. Find the names of person who live and work in the same city.
iv. Find the names of person who do not work for infosys.
v. Find the person whose salaries are more than that of all of the Oracle employees.
vi. Find the name of the companies that are located in the every city where company
infosys is located.

5. Consider the following database schema:

PROJECT ( Project#, Pname, Architect)


EMPLOYEE ( Emp#, Ename)
ASSIGNED_TO ( Project#, Emp# )

Solve the following queries using relational algebra :


a) Get the employee number of employees working on project COMP353
b) Get details of employees ( both number and name) working on project COMP353
c) Obtain details of employees working on the database project
d) Gather details of employees working on both COMP353 and COMP354
e) Find the employee numbers of employees who work on atleast all of the projects that employee
107 works on.
f) Find the employee number of employees who do not work on project COMP453.
g) Get the employee number of employees who work on all projects.

6. Discuss the following:


a) Microsoft SQL server
b) IBM DB2 Universal Database
c) MySQL
d) Oracle

7. Given the following set of FDs, find the minimum set of 3NF tables. Designate the
candidate key attributes of these tables and write each and every step of reduction of
FDs.

a. J KLMNP
b. JKL MNP
c. K MQ
d. KL MNP
e. KM NP
f. N KP

8. Consider the following relation:


CAR_SALE(Car#,Date_Sold,Salesman#,Commision%,Discount_Amount)

Assume that a car may be sold by multiple salesmen and hence (Car#,Salesman#) is the
primary key. Additional dependencies are:
Date_Sold -->Discount_Amount and

Salesman# -->Commision%

Based on the given primary key ,is this relation in 1NF, 2NF or 3NF? Why or Why not?
How would you successfully normalize it completely?

9. Convert the following query into a query tree:

SELECT P.Pnumber, P.Dnum, E.Lname, E.Address, E.Bdate


FROM PROJECT P, DEPARTMENT D, EMPLOYEE E
WHERE P.Dnum=D.dnumber AND D.Mgr_ssn= E.Ssn AND P.Plocation=’Stafford’;

10. Queries

i) Retrieve the name and address of all employees who work for the research
department.

ii) For each employee, retrieve the employee’s first name, last name and also the first
and last name of his/her immediate supervisor.

iii) Make a list of all project numbers for projects that involve an employee whose
last name is SMITH as a worker or as a manager of the department that controls
the project.

iv) For each employee, retrieve the project number, project name and the number of
employees from department number 5 who work on the project.

Consider the above SQL queries and perform the following:

a) Draw at least two query trees that can represent each of these queries. Under what
circumstances would you use each of your query tree?

b) Draw the initial query tree for each of these queries and then show how the query tree is
optimized by the algorithm based on heuristic query optimization.

c) For each query, compare your own query trees of part a) and the initial and final tree of
part b).
11. Given the following SQL query:
Student (sid, name, age, address)
Book(bid, title, author)
Checkout(sid, bid, date)

SELECT S.name
FROM Student S, Book B, Checkout C
WHERE S.sid = C.sid AND B.bid = C.bid AND B.author = ’Olden Fames’ AND
S.age > 12 AND S.age < 20
And assuming:
1. There are 10,000Student records stored on 1,000 pages•
2. There are 50,000 Book records stored on 5,000 pages•
3. There are 300,000 Checkout records stored on 15,000 pages•
4. There are 500 different authors•
5. Student ages range from 7 to 24.

(a) Show a physical query plan for this query, assuming there are no indexes and
data is not sorted on any attribute.
(b)Compute the cost of the query Plan

12. By testing for conflict serializability of schedule which of following are conflict
serializable schedule

a: r1(X);r3(X);w1(X);r2(X);w3(X);
b: r1(X);r3(X);w3(X);w1(X);r2(X);
c: r3(X);r2(X);w3(X);r1(X);w1(X);
d: r3(X);r2(X);r1(X);w3(X);w1(X);

13. Assume that the railway reservation system is implemented using an RDBMS. What are
the concurrency control measure one has to take, in order to avoid concurrency related
problems in the above system? How can the deadlock be avoided in this system?

14. Design a database for an airline. The database must keep track of customers and their
reservations, flights and their status, seat assignments on individual flights, and the
schedule and routing of future flights.Your design should include an E-R diagram, a set
of relational schemas, and a list of constraints, including primary-key and foreign-key
constraints.

You might also like