## Transactions

 Question 1

Two transactions T1 and T2 are given as

T1: r1(X)w1(X)r1(Y)w1(Y)
T2: r2(Y)w2(Y)r2(Z)w2(Z)

where ri(V) denotes a read operation by transaction Ti on a variable V and wi(V) denotes a write operation by transaction Ti on a variable V. The total number of conflict serializable schedules that can be formed by T1 and T2 is ____________.

 A 54 B 55 C 56 D 57
Database-Management-System       Transactions       GATE 2017(set-02)
Question 1 Explanation:
From the given transactions T1 and T2, total number of schedules possible = (4+4)!/4!4!
= 8!/(4×3×2×4×3×2)
= (8×7×6×5×4×3×2×1)/(4×3×2×4×3×2)
= 70
Following two conflict actions are possible:

∴# Permutations = 4 × 3 = 12

#permutations = 4 × 1 = 4
∴ Total no. of conflict serial schedules possible = 70 - 12 - 4 = 54
 Question 2

NOT a part of the ACID properties of database transactions?

 A Atomicity B Consistency C Isolation D Deadlock-freedom
Database-Management-System       Transactions       2016 set-01
Question 2 Explanation:
A transaction in a database system must maintain Atomicity, Consistency, Isolation and Durability – commonly known as ACID properties.
So, Deadlock – freedom is not there in the ACID properties.
 Question 3

Suppose a database schedule S involves transactions T1, ..., Tn. Construct the precedence graph of S with vertices representing the transactions and edges representing the conﬂicts. If S is serializable, which one of the following orderings of the vertices of the precedence graph is guaranteed to yield a serial schedule?

 A Topological order B Depth-ﬁrst order C Breadth-ﬁrst order D Ascending order of transaction indices
Database-Management-System       Transactions       GATE 2016 set-2
Question 3 Explanation:
If a schedule is conflict serializable then no cycle in precedence graph should be present.
But BFS and DFS are also potssible for cyclic graphs.
And topological sort is not possible for cyclic graph.
Moreover option (D) is also wrong because in a transaction with more indices might come before lower one.
 Question 4

Consider the following database schedule with two transactions, T1 and T2.

S = r2(X); r1(X); r2(Y); w1(X); r1(Y); w2(X); a1; a2

where ri(Z) denotes a read operation by transaction Ti on a variable Z, wi(Z) denotes a write operation by Ti on a variable Z and ai denotes an abort by transaction Ti.

Which one of the following statements about the above schedule is TRUE?

 A S is non-recoverable B S is recoverable, but has a cascading abort C S does not have a cascading abort D S is strict
Database-Management-System       Transactions       GATE 2016 set-2
Question 4 Explanation:
Given schedule is,

Now let's check statements one by one,
A) False, because there is no dirty read. So, it is recoverable.
B) False, because there is to dirty read. So, no cascading aborts.
C) True.
D) False, because there is Transaction T2 which written the value of x which is written by T1 before T1 has aborted. So, not strict.
 Question 5
 A Atomicity B Consistency C Isolation D Durability
Database-Management-System       Transactions       GATE 2015 -(Set-2)
Question 5 Explanation:
The consistency property ensures that the database remains in a consistent state before the (start of the transaction and after the transaction is over. Here sum of the accounts x & y should remain same before & after execution of the given transactions which refers to the consistency of the sum.
 Question 6
 A Undo T3, T1; Redo T2 B Undo T3, T1; Redo T2, T4 C Undo: none; redo: T2, T4, T3, T1 D Undo T3, T1; T4; Redo: T2
Database-Management-System       Transactions       GATE 2015 -(Set-2)
Question 6 Explanation:
As T1 & T3 are not yet committed they must be undone. The transactions which are after the latest checkpoint must be redone. So T2 must be redone. No need to redo the records which are before the last checkpoint, so T4 need not be redone.
 Question 7

 A T2 must be aborted and then both T1 and T2 must be re-started to ensure transaction atomicity B Schedule S is non-recoverable and cannot ensure transaction atomicity C Only T2 must be aborted and then re-started to ensure transaction atomicity D Schedule S is recoverable and can ensure atomicity and nothing else needs to be done
Database Management System       Transactions       GATE 2015(Set-03)
Question 7 Explanation:
T2 is reading the value written by T1 and getting committed before T1 commits. So it is non-recoverable schedule.
 Question 8
Consider the following four schedules due to three transactions (indicated by the subscript) using read and write on a data item x, denoted by r(x) and w(x) respectively. Which one of them is conflict serializable?
 A r1 (x); r2 (x); w1 (x); r3 (x); w2 (x) B r2 (x);r1 (x);w2 (x);r3 (x);w1 (x) C r3 (x);r2 (x);r1 (x);w2 (x);w1 (x) D r2 (x);w2 (x);r3 (x);r1 (x);w1 (x)
Database-Management-System       Transactions       GATE 2014(Set-01)
Question 8 Explanation:
Option: A

- Polygraph contains cycle. So, not a conflict serializable.
Option: B

-Cyclic
Option: C

- Cyclic
Option: D

- Acyclic, so conflict serializable.
 Question 9
 A S is conflict-serializable but not recoverable B S is not conflict-serializable but is recoverable C S is both conflict-serializable and recoverable D S is neither conflict-serializable nor is it recoverable
Database-Management-System       Transactions       Gate 2014 Set -02
Question 9 Explanation:

In the precedence graph, there are no cycles. So, it is conflict serializable and recoverable also.
 Question 10
 A a serializable schedule B a schedule that is not conflict serializable C a conflict serializable schedule D a schedule for which a precedence graph cannot be drawn
Database-Management-System       Transactions       Gate 2012
Question 10 Explanation:

The above schedule is not conflict serializable.
 Question 11

 A I only B II only C Both I and II D Neither I nor II
Database-Management-System       Transactions       2010
Question 11 Explanation:
― Two-phase locking protocol (2PLP) ensures the conflict serializable schedule but it may not free from deadlock.
― Timestamp ordering protocol ensures conflict serializability and free from deadlock.
 Question 12

 A T1 → T3 → T2 B T2 → T1 → T3 C T2 → T3 → T1 D T3 → T1 → T2
Database-Management-System       Transactions       2010
Question 12 Explanation:
The given schedule is

― Precedence graph for the above schedule is,

― From the precedence graph the correct serialization is,
 Question 13

 A S1 and S2 B S2 and S3 C S3 only D S4 only
Database-Management-System       Transactions       2009
Question 13 Explanation:
S1 has a cycle from T1→T2 and T2→T1 Schedule S2,

Dependency graph is,

So, there is no cycle.
Schedule S3,

Dependency graph is,

S4 also has a cycle T1→T2 and T2→T1.
So, S2 and S3 are conflict serializable.
 Question 14

 A S1, S2 and S3 are all conflict equivalent to each other B No two of S1, S2 and S3 are conflict equivalent to each other C S2 is conflict equivalent to S3, but not to S1 D S1 is conflict equivalent to S2, but not to S3
Database-Management-System       Transactions       Gate 2008-IT
Question 14 Explanation:
Two schedules are conflict equivalent when the precedence graph are isomorphic.
For S1:

For S2:

For S3:

Hence, S1 is conflict equivalent to S2, but not to S3.
 Question 15

 A Both S1 and S2 are conflict serializable. B S1 is conflict serializable and S2 is not conflict serializable. C S1 is not conflict serializable and S2 is conflict serializable. D Both S1 and S2 are not conflict serializable.
Database-Management-System       Transactions       Gate-2007
Question 15 Explanation:

In precedence graph of S1 since cycle is formed so not conflict serializable.
But in precedence graph of S2 No cycle is formed so it is conflict serializable.
 Question 16

 A We must redo log record 6 to set B to 10500. B We must undo log record 6 to set B to 10000 and then redo log records 2 and 3. C We need not redo log records 2 and 3 because transaction T1 has committed. D We can apply redo and undo operations in arbitrary order because they are idempotent.
Database-Management-System       Transactions       Gate-2006
Question 16 Explanation:
When the database system crashes after the transactions have committed then we need to redo the log records. And if the database system crashes before the transactions have committed then we need to undo the log records.
So from above theory we can say that option (B) is the correct answer.
 Question 17
Which of the following scenarios may lead to an irrecoverable error in a database system?
 A A transaction writes a data item after it is read by an uncommitted transaction B A transaction reads a data item after it is read by an uncommitted transaction C A transaction reads a data item after it is written by a committed transaction D A transaction reads a data item after it is written by an uncommitted transaction
Database-Management-System       Transactions       Gate-2003
Question 17 Explanation:
Irrecoverable error occurs when a transaction reads a data item after it is written by uncommitted transaction.
 Question 18

 A The schedule is serializable as T2; T3; T1 B The schedule is serializable as T2; T1; T3 C The schedule is serializable as T3; T2; T1 D The schedule is not serializable
Database-Management-System       Transactions       Gate-2003
Question 18 Explanation:
Precedence graph:

Cycle formed so not serializable.
 Question 19

 A This schedule is serialized and can occur in a scheme using 2PL protocol B This schedule is serializable but cannot occur in a scheme using 2PL protocol C This schedule is not serialiable but can occur in a scheme using 2PL protocol D This schedule is not seralisable and cannot occur in a scheme using 2PL protocol.
Database-Management-System       Transactions       Gate-1999
Question 19 Explanation:
Let's draw precedence graph,

Since cycle exist so not conflict serializable.
And we know that if the schedule is not serializable then it is not 2PL.
Hence correct option is (D).
There are 19 questions to complete.