DBMS Solution-7
DBMS Solution-7
Total Marks : 20
Question 1
Consider the following schedule S of transactions T1 and T2 .
The read operation on data item A is denoted by read(A) and the write operation on data
item A is denoted by write(A).
Marks: 2 MCQ
T1 T2
read(A)
A:=A-500
write(A)
read(C)
read(B)
B:=B+500
temp:=C∗0.5
C:=C-temp
write(B)
write(C)
read(D)
D:=D+temp
write(D)
c) S is serializable only as T1 , T2 .
d) S is serializable only as T2 , T1 .
Answer: a)
Explanation: First, swap all non-conflicting instructions of the above schedule S.
T1 and T2 both are working on the different data items.
So, S is serializable both as T1 , T2 and T2 , T1 .
Hence, option (a) is correct.
1
Question 2
Consider the following schedule S involving six transactions T1 , T2 , T3 , T4 , T5 and T6 :
Marks: 2 MCQ
T1 T2 T3 T4 T5 T6
R(X)
W(X)
R(Y)
W(Y)
W(X)
W(Y)
W(X)
R(Z)
W(Z)
Answer: c)
Explanation: If we draw the precedence graph of the transactions as shown in the fol-
lowing, we can observe that the graph has no cycle.
So, the above schedule is a conflict serializable schedule.
All conflict serializable schedules are view serializable too.
2
Question 3
Consider the following schedule S involving four transactions T1 , T2 , T3 and T4 .
Marks: 2 MCQ
T1 T2 T3 T4
R(X)
R(Z)
W(X)
R(Y)
W(Y)
W(X)
W(Y)
W(Z)
a) 1
b) 2
c) 3
d) 4
Answer: c)
Explanation: If we draw the precedence graph of the schedule, we can observe that the
graph has no cycle. Hence, the above schedule is conflict serializable schedules.
All possible topological orderings of the above precedence graph will be the possible
conflict serializable schedule.
1. T1 → T3 → T2 → T4
2. T1 → T2 → T3 → T4
3. T3 → T1 → T2 → T4
Hence, option c) is correct.
3
Question 4
Consider the following schedule S. Marks: 2 MCQ
T1 T2 T3
R(Y)
W(Y)
R(Y)
W(Y)
W(Y)
W(Z)
a) 1
b) 2
c) 3
d) 4
Answer: a)
Explanation: Step 1: Final Update on data item: Y-T1
Final Update on data item: Z-T1
Since the final update on Y and Z is made by T1, the transaction T1 must execute after all
the transactions: (T2,T3) → T1.
Step 2: Initial Read + Which transaction updates after read?
Y : T3 (initial read) then T2 firstly updates it.
Hence, the dependency is: T3 →T2
Step 3: Write Read Sequence: T2 firstly writes Y and then T1 reads Y.
Hence, the dependency is: T2 →T1
The ways we can arrange (T3→T2 → T1).
Hence, total possible view serializable schedule of S= 1.
Hence, option (a) is correct.
4
Question 5
Suppose in a database, there are four transactions T1 , T2 , T3 and T4 . Transaction T1 is
waiting for transactions T2 and T4 , transaction T2 is waiting for transaction T3 and T4 ,
and transaction T3 is waiting for transactions T4 to release a data item.
Identify the correct wait-for graph for the above scenario. Marks: 2 MCQ
a)
b)
c)
d)
Answer: b)
Explanation: When Ti requests a data item currently being held by Tj , then the edge Ti →
Tj is inserted in the wait-for graph. Ti → Tj , implying that Ti waiting for Tj to release a
data item.
Hence, option b) is correct.
5
Question 6
Consider two transactions given below where lock-X(A) denotes Ti has obtained an Exclusive-mode
lock on item A and lock-S(A) denotes Ti has obtained a Shared-mode lock on item A.
Marks:2 MCQ
T1
lock-X(A)
read(A)
A:= A-100 T2
write(A) lock-X(A)
lock-X(B) read(A)
read(B) write(A)
B:= B+100 lock-S(B)
write(B) read(B)
lock-S(C) unlock(B)
read(C) commit
commit unlock(A)
unlock(A)
unlock(B)
unlock(C)
Answer: c)
Explanation: Transaction T1 first commits and then unlocks all locks(Exclusive-mode lock
and Shared-mode lock). That is why, T1 follows the rigorous two-phase locking protocol.
But transaction T2 first unlocks all Shared-mode lock and then commits. After commit,
it unlocks Exclusive-mode lock . That is why, it follows the strict two phase locking
protocol but not rigorous two-phase locking protocol.
So, option (c) is correct.
6
Question 7
Suppose in a database, there are three transactions T1 , T2 and T3 with timestamp 12, 14 and
16 respectively. T1 is holding a data item which T2 and T3 are requesting to acquire. Which
of the following statement(s) is (are) correct in respect of Wound-Wait Deadlock Prevention
scheme? Marks: 2 MSQ
Answer: a), b)
Explanation: Wound-Wait Deadlock Prevention scheme: When TA1 requests data item held
by TA2 (older means smaller timestamp), two cases may arise.
• If TA1 is older than TA2 then TA1 wounds TA2 (TA2 will be aborted).
• If TA1 younger to TA2 then TA1 will wait for release the data item held by TA2.
7
Question 8
Consider the following schedule S. Marks: 2 MCQ
T1 T2 T3
R(Y)
R(Z)
W(Y)
R(Y)
W(Y)
R(Y)
W(Y)
abort
Answer: c)
Explanation: As per the cascading rollback a single transaction failure leads to a series of
transaction rollbacks.
Hence, if T1 fails(aborted), both T2 and T3 must also be rolled back.
So, option (c) is correct.
8
Question 9
Consider the following schedule S. Marks: 2 MCQ
T1 T2
R(X)
W(X)
R(Y)
R(X)
COMMIT
W(X)
COMMIT
Answer: a)
Explanation: Recoverable schedule: If a transaction Tj reads a data item previously written
by a transaction Ti , the commit operation of Ti must appear before the commit operation of
Tj .
Cascadeless schedules: For each pair of transactions Ti and Tj such that Tj reads a data item
previously written by Ti , the commit operation of Ti appears before the read operation of Tj .
So option (a) is correct.
9
Question 10
Identify the correct option(s) which is (are) used in Transaction Control Language (TCL).
Marks: 2 MCQ
a) Alter
b) Insert
c) Update
d) Savepoint
Answer: d)
Explanation:The following commands are used to control transactions: Commit, Rollback,
Savepoint and Set Transaction.
So, option (d) is correct.
10