You are on page 1of 52

DESIGN AND ANALYSIS OF ALGORITHMS

UNIT-IV
(TRANSACTION SYSTEM)
Introduction to Transaction
 What is Transaction?
ACID Properties
ACID Properties
Example-
Transaction States
Every Transaction has following states-
Concurrent Execution of Transaction
 Transactions are allowed to execute concurrently to achieve following-
 increased processor and disk utilization-
 leading to better transaction throughput: one transaction can be using the CPU
while another is reading from or writing to the disk
 reduced average response time for transactions-
 short transactions need not wait behind long ones.
Why Concurrency Control is needed?
 When the transactions are executed concurrently they may produce the wrong
result.
Serializability of Schedules

 Schedule-
 Serial Schedule-

 Serializable Schedule
1. Conflict Serializability

 Conflict Serializable-

 Conflict Equivalent-
1. Conflict Serializability (cont………..)
Examples 1- Testing of conflict Serializability

T1 T2
R(A)
W(A)
R(B)
W(B)
R(A)
W(A)
Examples 2- Testing of conflict Serializability
T1 T2 T3
R(Z)
R(Y)
W(Y)
R(Y)
R(Z)
R(X)
W(X)
W(Y)
W(Z)
R(X)
R(Y)
W(Y)
Examples 3- Testing of conflict Serializability
T1 T2 T3
R(Y)
R(Z)
R(X)
W(X)
W(Y)
W(Z)
W(Z)
R(Y)
W(Y)
R(Y)
W(Y)
R(X)
W(X)
Q. Which of the following schedules are conflict Serializable. For each Serializable schedule determine
the equivalent serial schedule.
1. R1(X), R3(X), W1(X), R2(X), W3(X)

2. R1(X), R3(X), W3(X), W1(X), R2(X)

3. R3(X), R2(X), W3(X), R1(X), W1(X)

4. R3(X), R2(X), R1(X), W3(X), W1(X)


2. View Serializability

 View Serializable-

 View Equivalent-
Consider the following schedules S1 and S2

T1 T2 T1 T2
R(A)
A=A-50 R(A)
W(A) A=A-50
W(A)
R(B)
R(A) B=B+50
A=A+50 W(A)
R(B)
B=B+50 R(A)
W(A) A=A+50
W(A)
W(A)
T1 T2 T3
R(Q)
W(Q)
W(Q)
W(Q)
DBMS

UNIT-IV
(LOCK-BASED PROTOCOLS)
Check points (Check point based Recovery)
Time Stamp (TS) based Protocol

You might also like