100% found this document useful (1 vote)
96 views10 pages

DBMS Solution-7

The document describes an assignment on database management systems. It contains 8 multiple choice questions regarding transaction scheduling, serialization, locking protocols, and deadlock handling. The questions cover topics like serializable schedules, wait-for graphs, two-phase locking, and wound-wait deadlock prevention. Sample transaction schedules are given for each question along with the correct answers and explanations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
96 views10 pages

DBMS Solution-7

The document describes an assignment on database management systems. It contains 8 multiple choice questions regarding transaction scheduling, serialization, locking protocols, and deadlock handling. The questions cover topics like serializable schedules, wait-for graphs, two-phase locking, and wound-wait deadlock prevention. Sample transaction schedules are given for each question along with the correct answers and explanations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Database Management System: Assignment 7

Total Marks : 20

February 24, 2023

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)

Which of the following is TRUE about the schedule S?

a) S is serializable both as T1 , T2 and T2 , T1 .

b) S is not serializable neither as T1 , T2 nor T2 , T1 .

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)

R(X) denotes read operation on data item X by transaction Ti .


W(X) denotes write operation on data item X by transaction Ti .
Choose the correct option for the above transaction schedule.

a) The schedule is only view serializable schedule.

b) The schedule is only conflict serializable schedule.

c) The schedule is both view and conflict serializable schedule.

d) The schedule is neither conflict serializable nor view serializable schedule.

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.

So, option (c) is correct

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)

R(X) denotes read operation on data item X by transaction Ti .


W(X) denotes write operation on data item X by transaction Ti .
Identify the possible number of conflict serializable schedules of the above schedule S.

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)

R(Y) denotes read operation on data item Y by Transaction Ti .


W(Y) denotes write operation on data item Y by Transaction Ti .
Identify the possible number of view serializable schedule of the above schedule S.

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)

Which of the following statement is (are) true?

a) Both T1 and T2 follow the rigorous two-phase locking protocol.

b) Both T1 and T2 do not follow the rigorous two-phase locking protocol.

c) Only T1 follows the rigorous two-phase locking protocol.

d) Only T2 follows the rigorous two-phase locking protocol.

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

a) Transaction T2 will wait for T1 to release the data item.

b) Transaction T3 will wait for T1 to release the data item.

c) Transaction T2 will be aborted.

d) Transaction T3 will be aborted.

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.

In this case Transaction T2 and T3 are younger in respect of Transaction T1 .


Hence, options a) and b) are correct.

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

R(Y) denotes read operation on data item Y by Transaction Ti .


W(Y) denotes write operation on data item Y by Transaction Ti .
Identify the correct statement(s) based on the above schedule S.

a) If T1 fails(aborted), only T2 must be rolled back.

b) If T1 fails(aborted), only T3 must be rolled back.

c) If T1 fails(aborted), both T2 and T3 must be rolled back.

d) If T1 fails(aborted), neither T2 nor T3 must be rolled back.

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

R(X) denotes read operation on data item X by Transaction Ti .


W(X) denotes write operation on data item X by Transaction Ti .
Choose the correct options for the above schedule.

a) The schedule is only recoverable schedule.

b) The schedule is only cascadeless schedule.

c) The schedule is recoverable schedule and cascadeless schedule both.

d) The schedule is neither recoverable nor cascadeless schedule.

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

You might also like