DBMS UNIT 5 Part 1
DBMS UNIT 5 Part 1
Transaction
Management
Prof. Firoz Sherasiya
9879879861
[email protected]
Database Management System (2130703) Darshan Institute of Engineering & Technology
What is transaction?
A transaction is a sequence of operations performed as a single
logical unit of work.
A transaction is a logical unit of work that contains one or more
SQL statements.
Works as a single
Example of transaction logical unit
read (A)
A = A – 50
Transaction write (A)
Operations
read (B)
B = B + 50
write (B)
Active
• This is the initial state.
• The transaction stays in this state while it is executing.
Partial Committed
• When a transaction executes its final operation/ instruction, it is said to be in a
partially committed state.
Failed
• Discover that normal execution can no longer proceed.
• Once a transaction cannot be completed, any changes that it made must be
undone rolling it back.
restored to its state prior to the start of the transaction. Two options
after it has been aborted:
□ restart the transaction
Read (A)
A = A - 50
Write (A)
Read (B)
B = B + 50
Write (B)
Commit
2. li = read(Q), lj = write(Q) T1 T2 T1 T2
read (Q) write(Q)
li and lj conflict
write(Q) read (Q)
3. li = write(Q), lj = read(Q) T1 T2 T1 T2
li and lj conflict write(Q) read (Q)
read (Q) write(Q)
4. li = write(Q), lj = write(Q)
T1 T2 T1 T2
li and lj conflict write(Q) write(Q)
write(Q) write(Q)
Unit – 6: Transaction Management 31 Darshan Institute of Engineering & Technology
Conflicting instructions
Instructions li and lj conflict if and only if there exists some item Q
accessed by both li and lj, and at least one of these instructions
wrote Q.
If both the transactions access different data item then they are
not conflict.
S1 S2
T1 T2 T3 T1 T2 T3
Write (A) Read (A)
Read (A) Write (A)
Write (A) Write (A)
Prepare
Phase
Commit
Phase
Coordinator
Coordinator
Participant
Send toinform
send
“ack” send to do
reply
inform
commit
request asking
whether ready for
commit readyor
todone
to commit
commit
not or not