0% found this document useful (0 votes)
3 views21 pages

Transaction Management in DBMS

This document covers transaction management in database systems, focusing on concurrency control and the ACID properties of transactions: Atomicity, Consistency, Isolation, and Durability. It explains transaction states, serializability, conflict equivalent schedules, and methods for testing conflict serializability. Additionally, it discusses the concepts of view serializability and the importance of maintaining database consistency during concurrent transactions.

Uploaded by

minaldhiman04
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views21 pages

Transaction Management in DBMS

This document covers transaction management in database systems, focusing on concurrency control and the ACID properties of transactions: Atomicity, Consistency, Isolation, and Durability. It explains transaction states, serializability, conflict equivalent schedules, and methods for testing conflict serializability. Additionally, it discusses the concepts of view serializability and the importance of maintaining database consistency during concurrent transactions.

Uploaded by

minaldhiman04
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

UNIT-5

Transaction Management

Dr. Kalpna Guleria


Associate Professor (Research) - Chitkara University, Punajb

14/10/2025 DBMS Dr. KALPNA GULERIA 1


Unit-5
Introduction to Concurrency Control
Transaction Properties
Transaction State
Serializability
 Conflict Equivalent Schedule
 Conflict Serializable Schedule
 Testing for Conflict Serilizability of a Schedule

14/10/2025 DBMS Dr. KALPNA GULERIA 2


 Transaction Properties
 Transaction State
 Serializability

14/10/2025 DBMS Dr. KALPNA GULERIA 3


ACID Properties
 Atomicity: Either all operations of the transaction are executed or
none of them.
 Consistency: Execution of a transaction in isolation preserves the
consistency of the database.
 Isolation: Although multiple transactions may execute concurrently,
each transaction must be unaware of other concurrently executing
transactions.
 Durability : After a transaction completes successfully, the changes
it has made to the database persist, even if there are system failures.

14/10/2025 DBMS Dr. KALPNA GULERIA 4


Example : Transaction T1 to transfer $50 from account A ($ 1000) to account B ( $2000)

 Atomicity requirement – If the transaction fails after step 3 and before step 6,
the system should ensure that its updates are not reflected in the database,
else an inconsistency will result.
 Consistency requirement – the sum of A and B is unchanged by the
execution of the transaction.
Before Execution of T1: A+B--> 1000+2000= 3000
After Execution of T1 : A 950, B2050
: A+B= 950+2050  3000
 Isolation requirement – if between steps 3 and 6, another transaction is
allowed to access the partially updated database, it will see an inconsistent
database (the sum A + B will be less than it should be) : A 950,
B2000
Transaction : T1
14/10/2025
A+B= 950+2000
DBMS
 2950 Dr. KALPNA GULERIA 5
Example of Fund Transfer : Contd…
Transaction to transfer $50 from account A to account B:

 Isolation- can be ensured by running transactions serially,


that is one after the other. However, executing multiple
transactions concurrently has significant benefits in DBMS
throughput.

 Durability – Once the transaction successfully completed,


all the changes reflected in the local variables must be
permanently stored into the database.
Transaction : T1
A 950, B2050
14/10/2025 DBMS Dr. KALPNA GULERIA 6
Transaction State
• Active – The initial state; the transaction stays in this state while it is
executing

• Partially committed – after the final statement has been executed.

• Failed -- after the discovery that normal execution can no longer proceed.
• Aborted – A transaction that fails to successfully complete its execution
will have an abort instruction as the last statement. In this case, the
transaction will be rolled back and the database restored to its state prior to
the start of the transaction. Two options after it has been aborted:

• Restart the transaction - can be done only if no internal logical error


• Kill the transaction

 Committed – A transaction that successfully completes its execution will


have a commit instructions as the last statement.
14/10/2025 DBMS Dr. KALPNA GULERIA 7
Transaction State Cont…

14/10/2025 DBMS Dr. KALPNA GULERIA 8


Schedules
Schedule –
A schedule consist of all the instructions of all concurrent
transactions. And it must preserve the order in which the
instructions appear in each individual transaction.

14/10/2025 DBMS Dr. KALPNA GULERIA 9


Serial Schedule
Let T1 transfer $50 from A to B, and T2 transfer 10% of the balance from A to B.
A Serial Schedule where T1 is followed by T2 A Serial Schedule where T2 is followed by T1

14/10/2025 Schedule 1 Schedule 2 10


DBMS Dr. KALPNA GULERIA
Prerequisite contd…
Serializability
• Basic Assumption –

1. Serial execution of a set of transactions preserves database consistency.

2. We ignore operations other than read and write instructions to have


simplified view of transactions.

3. We assume that transactions may perform arbitrary computations on


data in local buffers in between reads and writes.
• A concurrent schedule is serializable if it is equivalent to a serial
schedule.

14/10/2025
Prerequisite contd…

Conflicting Instructions

Instructions li and lj of transactions Ti and Tj respectively, conflict if and


only if there exists some item Q accessed by both li and lj, and at least one
of these instructions write Q.
1. li = read(Q), lj = read(Q). li and lj don’t conflict.
2. li = read(Q), lj = write(Q). They conflict.
3. li = write(Q), lj = read(Q). They conflict
4. li = write(Q), lj = write(Q). They conflict

14/10/2025
Prerequisite contd…

Serializability contd..
1. Serial Schedule :

Serial schedule consists of a sequence of instructions from various transactions, where the instructions belonging
to one single transaction appear together in that schedule.

2. Conflict Equivalent Schedule:

If a schedule S can be transformed into a schedule S’ by swapping a series of non-conflicting instructions, we


say that S and S’ are conflict equivalent.

3. Conflict Serializable Schedule :

A concurrent schedule is Serializable Schedule if it is conflict equivalent to a serial schedule. Different forms
of schedule equivalence are :

A. Conflict serializability
14/10/2025
B. View serializability
Prerequisite contd…
Schedule
 Let T1 and T2 be the transactions defined previously.
 The following schedule 3 and Schedule 4 are not serial schedules.

 In Schedules 1, 2 and 3, the sum A + B is preserved but in Schedule 4 , the Sum A+B does
not preserve the value hence Schedule 4 is not conflict equivalent to Schedule 1.

14/10/2025
Schedule 1 Schedule 3 Schedule 4
Prerequisite contd…
Conflict Serializability (Cont.)
• Schedule 3 can be transformed into Schedule 6, a serial schedule where T2 follows T1, by
series of swaps of non-conflicting instructions.
• Therefore Schedule 3 is conflict serializable.

Schedule 3 Schedule 3 Schedule 6


14/10/2025
Quick Recap of Conflict
Serializability

14/10/2025
Prerequisite contd…

Conflict Serializability Contd..

• Example of a schedule that is not conflict serializable:

• We are unable to swap instructions in the above schedule to


obtain either the serial schedule < T3, T4 >, or the serial
schedule < T4, T3 >.

14/10/2025
Prerequisite contd…

Testing for Serializability


• Consider some schedule of a set of transactions T1, T2, ..., Tn
• Precedence graph — a direct graph where the vertices are the
transactions (names).
• We draw an arc from Ti to Tj if the two transaction conflict, and Ti
accessed the data item on which the conflict arose earlier.
• We may label the arc by the item that was accessed.
• Example 1 x

14/10/2025
View Serializability
• Let S and S´ be two schedules with the same set of transactions. S and S´ are view
equivalent if the following three conditions are met, for each data item Q,
1. If in schedule S, transaction Ti reads the initial value of Q, then in schedule S’
also transaction Ti must read the initial value of Q.
2. If in schedule S transaction Ti executes read(Q), and that value was produced
by transaction Tj (if any), then in schedule S’ also transaction Ti must read the
value of Q that was produced by the same write(Q) operation of transaction Tj
3. The transaction (if any) that performs the final write(Q) operation in schedule
S must also perform the final write(Q) operation in schedule S’.
As can be seen, view equivalence is also based purely on reads and writes alone.

DBMS Dr. KALP 19


NA GULERIA
Prerequisite contd…

View Serializability Contd…


• A schedule S is view serializable if it is view equivalent to a serial schedule.
• Every conflict serializable schedule is also view serializable.

• What serial schedule is above equivalent to?


• Every view serializable schedule that is not conflict serializable has blind writes.

14/10/2025
Schedule 1 Schedule 3
Thanks !

14/10/2025 DBMS Dr. KALPNA GULERIA 21

You might also like