Indian Statistical Institute: PGDBA, First Year, Final of First Semester Examination, 2019-20
Indian Statistical Institute: PGDBA, First Year, Final of First Semester Examination, 2019-20
5 × 10 = 50
1. (a) What will be returned as a result of natural join of a table to itself in case of the
following scenarios? Justify your answers.
(i) The table has a primary key.
(ii) The table has duplicate tuples but non-null entries.
(b) Consider the following schema. It represents the record low and record high AQI
(standing for air quality index) values calculated for different major cities across the
world over the last few decades.
AQI = <cid : integer; cname : string; recordlow : real; recordhigh : real; year : integer>
The primary key is underlined in the above schema. What will be returned by the
following SQL queries? Justify your answer.
(i) select cname from AQI group by cid having min(recordhigh) <= 300;
(ii) select A1.cname from AQI as A1, (select max(recordlow) as REC_LOW from
AQI) as A2 where A1.recordlow = A2.REC_LOW;
4+(3+3)
2. (a) Consider the relations R1(A, B), R2(B, C), and the following SQL query.
(i) Are the following two logical plans in relational algebra equivalent based on the
aforementioned schemas?
(ii) If not equivalent, justify why. If so, indicate and justify which one is likely to be
more efficient than the other.
(b) Consider a pair of relations R1 and R2, with t1 and t2 number of tuples, respectively. The
primary key of R1 is the only foreign key of R2. Estimate the maximum size of the
following query that includes a semi-join operation.
R1 ⋉ R2
(1+4)+5
1
3. (a) Consider the following table, with no primary key, representing the appointment
details of patients for surgeries in a hospital.
Transaction T1 Transaction T2
read(X)
X ← X – 10
write(X)
read(X)
T ← X * 0.05
X←X–T
write(X)
read(Y)
Y ← Y + 10
write(Y)
commit
read(Y)
Y←Y+T
write(Y)
commit
(b) Recall the concurrency control protocol based on multiple granularity of the database in
which the following locking models are considered.
IS - Intention-shared lock
IX - Intention-exclusive lock
S - Shared lock as used conventionally
SIX - Shared and intention-exclusive lock
X - Exclusive lock as used conventionally
2
Identify the inaccurate entries in the following lock compatibility table.
IS IX S SIX X
IS True True True True True
IX True True True True False
S True True True False False
SIX True True False False False
X True False False False False
7+3
5. Consider the following collection of documents, in JSON format and created in NoSQL
environment within MongoDB, named as PROJECT.
{
"FName" : "Debapriyo Majumdar",
"Subject" : "Computing for Data Sciences",
"Presentations" : [
{
"Date" : "25-11-2019"
},
{
"Date" : "12-12-2019"
}
]
}
{
"FName" : "Malay Bhattacharyya",
"Subject" : "Fundamentals of Database Systems",
"Presentations" : [
{
"Date" : "14-12-2019"
}
]
}
{
"FName" : "Debasis Sengupta",
"Subject" : "Stochastic Processes & Applications"
}
What will the following queries return? Justify your answer.
(i) db.PROJECT.find({ $and : [{ "FName" : { $regex : /^D.ba/ } }, { "FName" : { $regex :
/R$/i } } ] });
(ii) db.PROJECT.find( { "Presentations.Date" : { $ne : "12-12-2019" } } );
5+5
6. Cite appropriate examples that satisfy the following requirements with proper justifications.
(i) A pair of relations with non-null entries on which left outer join and Cartesian product
will return the same result.
(ii) Uncommitted dependency between a pair of transactions.
5+5