DBMSEnd Sem Winter 2017 Solution
DBMSEnd Sem Winter 2017 Solution
< START U > ;< U, A, 10, 5 >; < START V >; < U, B, 20, 15 >; < V, C, 30, 25 > ;<
COMMIT V >; < START CKPT(U) >; < START W >; < U, D, 40, 30 > ;< W, E, 50, 35 >;
< END CKP T >; < W, F, 60, 45 >
a) Is the following state of database elements (on disk) possible at the time of
crash? Justify your answer.
A = 5, B = 15, C = 25, D = 40, E = 35, F = 45
b) What are the values of the database elements (A=?, B=?, C=?, D=?, E=?, F=?)
after a successful recovery?
c) What different compensation log records will be written in the log during
recovery?
Answer:
a) [1 + 2 marks] Yes. Before checkpointing, all updates must be on disk, remaining may
or may not be there.
b) [4 marks. No partial marking.] A = 10, B = 20, C = 25, D = 40, E = 50, F = 60.
Transaction U,W are undone. V had already committed and was not active at start of
checkpoint, hence its effect has been reflected on the disk already.
c) [3 marks. No partial marking.] Compensation log records will be as follows:
<U, A, 10>
<U, B, 20>
<U, D, 40>
<W, E, 50>
<W, F, 60>
Or
<W, F, 60>
<W, E, 50>
<U, D, 40>
<U, B, 20>
<U, A, 10>
Question-2:
a) [3 Marks] Suppose there are eight transactions T1, T2, ..., T8, of which the
odd-numbered transactions, T1, T3, T5 and T7, lock the root of the tree, in that
order. There are three children of the root, first locked by T1, T2, T3 and T4 in
that order. The second child is locked by T3, T6, and T5 in that order, and the
third child is locked by T8 and T7, in that order. Give one example of a serial
order that is consistent with these statements if transactions are assumed to
follow Tree protocol.
Answer:
i) [1 mark.] No. There is cycle in precedence graph.
ii) [1 mark for correct example.]
T1 T2 T3
R1(A)
W2(A)
W2(B)
R1(A)
W3(B)
We are interested to know the level of concurrency one should associate with
transaction T1 to make the schedule feasible, when T2 has been assigned
conflict-serializable level. Answer and reason for each of the four levels, whether the
schedule will be feasible or not if that level is assigned to transaction T1.
Answer: [0.25 for mentioning the isolation level is feasible or not + 0.25 marks for
correct justification for each part.]
Repeatable read - Not feasible. Reason: T2 updates the data item read by transaction
T1.
Read uncommitted - Feasible.
Read committed - Feasible Reason: T1 reads the data item committed by T2.
Serializable - Not Feasible
Suppose we want to find the maximum grade of the CSE202 class in Winter 2002 term.
Assume that there is no other index on Enroll. Which one of the following four options
will likely provide the biggest performance improvement for the query? Briefly justify
your answer for each option.
[1 mark each for option a, b and d with justification why that is not best option. 2 marks
for option c with justification why this is best option.]
Answer: Best Option: C) Create a cluster index on Enroll(courseId) and another index
on Enroll(Term)
By using the index on courseID attribute get the block addresses for CSE 202 course.
Use the index on attribute Term to get the block addresses that have Winter2002 term
records. Then intersection of these block addresses would give us the desired blocks
addresses. Start scanning the file from the block address with the least course ID in the
increasing order of block addresses to get the result records. The number of Disk IOs
will be less than equal to the number of result tuples in addition to index accesses.
However, generally it is going to be very less as the index is clustered on courseID and
hence most of the result records will be highly likely together on the same blocks.
Explanation:
Option (A) is not good as it will result into linear scan of complete file.
Option(B) is not good as indices do not help at all. If any or both indices are used, the
number of Disk IOs will be equal to number of records in addition to accesses made for
index structure accesses.
Option(D) is not good as the number of Disk IOs will be equal to the number of students
enrolled for CSE202 course in Winter 2002 term, i.e. the number of tuples which satisfy
this condition.
Question-4:
a) [4 Marks] Consider a relation R with six attributes ABCDEF. The following
functional dependency, F1 = A à BCDEF, holds over R. Your task is to come up
with two other functional dependencies, F2 and F3, which satisfy the following
three properties.
1) Neither F2 nor F3 can be inferred from F1 using Armstrong’s axioms
2) Relation R with functional dependencies F1 and F2 is in BCNF
3) Relation R with functional dependencies F1, F2, and F3 is in 3NF but not in
BCNF
[0.5 mark each for F2 and F3 if they are non trivial. 1.5 mark if F2 makes relation R in
BCNF. 1.5 marks if F2 and F3 makes relation R in 3NF but not in BCNF.]
Answer:
F2: BC→ADEF
F3: D→C
F2 and F3 cannot be derived from F1 by any of reflexivity, transitivity, augmentation
axiom.
Key is A and BC with R based on F1 and F2 only . None of D,E,F are dependent on a
proper subset of the keys, hence relation is in 2NF. For F1 and F2, LHS is a superkey,
hence relation is in 3NF as well as BCNF.
Key is A and BC for R based on F1 ,F2 and F3. Due to same reasons as above, R is in
2NF. For F1,F2,F3, either LHS is a superkey or RHS is a primary key attribute, hence R
is in 3NF. However, D → C violates the property for BCNF as D is not a superkey.
b) [6 Marks] Consider relation R with six attributes ABCDEF and the following
functional dependencies: A → CDF, D → A, DF → E. We decompose R into
two relations, ABCD and DEF.
i) Is this decomposition a lossless join decomposition? Briefly justify your answer.
[3 marks. No partial marking. ]
ii) Is this decomposition a dependency-preserving decomposition? Briefly justify
your answer. [3 marks. No partial marking.]
Answer:
a)
● R1 ⋃ R2 = R
● R1⋂R2 = D
● D → A, A → CDF. By transitivity, D → CDF ,so D → DF. As, DF → E,
hence, D → DEF.
● Hence, R1⋂R2→R2, which is a lossless decomposition.
b) F1={D → A}, F2={DF → E}
X → Y in F
Z=X
While changes to Z occur do
for i ← 1 to n do
Z = Z ⋃ ((Z ⋂ Ri) ⋂ Ri) w.r.t F
if Y is a subset of Z then return true
else return false;
Hence, this is dependency preserving decomposition.
Question-5: [5 Marks] Draw an ER-diagram that captures the following two SQL
statements.
[2 marks for cardinality constraint. 1 mark each for participation constraints on each
side. 0.5 mark for each of the two entity set(defined attributes and primary key)]
Answer: