You are on page 1of 3

BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI

PILANI CAMPUS
SECOND SEMESTER 2015 – 2016
DATABASE SYSTEMS (CS F212/ IS F243)
MID SEMESTER EXAM
Date: 16.03.2016 Weightage: 25 % (50 M)
Duration: 90 min. Type: Closed Book
Note: Answer all parts of the question together.
Answers must be brief. Total no. of pages: 2
Q1. Answer the following briefly: [5*2=10 Marks]
a) State true or false:
i. Secondary indices are sparse. (True/False)
ii. S ⋈ R = S × R, if S and R don’t share any attributes, and S ⋈ R = S ∪ R, if S and R have the same
attributes. (True/False)
iii. Consider relations R (A, B) and S (B, C). If B is a primary key for S, then R ⋈ S may contain more
tuples than R does. (True/False)
iv. Projection operators commute i.e., πX (πY (R)) = πY (πX (R)), holds for every relation R and all sets of
attributes X and Y. (True/False)
b) What are insertion and deletion anomalies? Explain with example.
c) State how a generalization relationship converts into a relational schema? State the primary key and the
attributes of this schema?
d) Prove that if schema R is in 3NF and every key is simple, then R is in BCNF.
e) Given a Mean-time-to-Failure (MTTF) as 100, 000 hours, what does this statement signify? If we use block-
level striping to store the data in 100 disks, then what will be the MTTF for the system?

Q2. Given the following FDs over relation with attributes R (ABCDEF):
[3+2+4+4+2= 15 marks]
BAE C
CE A
AEF C
CEF AD
CEAF D
CEF A
a) Compute a minimal cover for the FDs. You should show explicitly the extraneous attributes you erase to
derive the minimal cover.
b) Find all keys of R.
c) Do a decomposition of R using 3NF synthesis, show all resulting tables and FDs over those tables.
d) Check if any of the tables is not in BCNF, and if so, decompose it further using BCNF decomposition.
e) Is the final result a dependency preserving decomposition?

Q3. Consider a schema R (ABCDEG) and the FD set F with F given as F = {ABC, ACB,
ADE, BD, BCA, EG}. Answer the following with steps:
[2+3=5 Marks]
a) What is the current normal form of R? Justify.
b) If R is decomposed into D = {ABC, ACDE, ADG}, determine if decomposition D is lossless-join and
dependency preserving. Solve the above problem with steps and provide justification where appropriate.

Q4. Given the following E-R diagram of a shopping system, answer the following: [6+4=10
Marks]

1
a) Convert the ER diagram into a relational model. Also identify the primary key and foreign key constraints
for each relational schema in the model.
b) Suppose we want to represent the relationship “purchased” with attribute “accessories” between a new
entity set “item” with customer, order and vendor. Consider this relationship to item as many to one (i.e. one
item can participate in the “purchased” relationship”). Use aggregation to represent the above information in
the ER diagram and convert the relationship “purchased” into the relational schema. In the schema, identify
the primary key. Also, identify the foreign key constraints. Consider the attributes of item as “item_id” and
“item_ name” with item_id as its primary key.

Q5. Write Relational Algebra Query for following using given schema: [1+1+2+2+2+2=10 Marks]
Doctor (SSN, FirstName, LastName, Specialty, YearsOfExperience, PhoneNum)
Patient (SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN)
Medicine (TradeName, UnitPrice, GenericFlag)
Prescription (Id, Date, Doctor_SSN, Patient_SSN)
Prescription Medicine (Prescription Id, TradeName, NumOfUnits)
 The Doctor relation has attributes Social Security Number (SSN), first and last names, specialty, the
number of experience years, and the phone number.
 The Patient relation has attributes SSN, first and last names, address, date of birth (DOB), and the SSN
of the patientʼs primary doctor.
 The Medicine relation has attributes trade name, unit price, and whether or not the medicine is generic
(True or False).
 The Prescription relation has attributes the prescription id, the date in which the prescription is written,
the SSN of the doctor who wrote the prescription, and the SSN of the patient to whom the prescription
is written.
 The Prescription_Medicine relation stores the medicines written in each prescription along with their
quantities (number of units).
a) List the first and last name of patients whose primary doctor named ʻJohn Smithʼ.
b) List the first and last name of doctors who are not primary doctors to any patient.
c) For medicines written in more than 20 prescriptions, report the trade name and the total number of units
prescribed.
d) List the SSN of patients who have ʻAspirinʼ and ʻVitaminʼ trade names in one prescription.

2
e) List the SNN of distinct patients who have ʻAspirinʼ prescribed to them by doctor named ʻJohn Smithʼ.
f) List the first and last name of patients who have no prescriptions written by doctors other than their
primary doctors.

You might also like