Uojlrvhaosd I ACKw
Uojlrvhaosd I ACKw
Uojlrvhaosd I ACKw
UNIT-IV
LEARNING MATERIAL
1. Transaction Concept
Transaction: A transaction is a unit of program execution that
accesses and possibly updates various data items. As an example
consider the following transaction that transfers $50 from account A to
account B. It can be written as:
1. read(A)
2. A := A – 50
3. write(A)
4. read(B)
5. B := B + 50
6. write(B)
This transaction consists of 6 actions that need to takes place in order to
transfer $50 from account A to account B.
T1 T2
1. read(A)
2. A := A – 50
3. write(A)
read(A), read(B), print(A+B)
4. read(B)
5. B := B + 50
6. write(B)
completes successfully (i.e., the transfer of the $50 has taken place), all
the updates that it carried out on the database persist, even if there is a
system failure after the transaction completes execution.
3. 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, after the transaction has been rolled back and the database has
been restored to its state prior to the start of the transaction
Committed, after successful completion
T1: read(A);
A := A − 50;
write(A);
read(B);
B := B + 50;
write(B).
5. Serializability
The database system must control concurrent execution of transactions, to
ensure that the database state remains consistent.
For this, we must first understand which schedules will ensure consistency,
and which schedules will not. For this, we need to consider simplified view
of transactions.
Simplified view of transactions
Schedule 7
5.2 View Serializability
Let S and S1 be two schedules with the same set of transactions. The
schedules S and S1 are said to be view equivalent if 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.
Schedule (c)
The schedules shown above are conflict serializable schedules since, their
precedence graphs are acyclic.
The following schedule is not conflict serializable as its precedence graph
consists a cycle.
6. Recoverability
If a transaction Ti fails, we need to undo the effect of this transaction to
ensure the atomicity property of the transaction.
In the following sections, we address the issue of what schedules are
acceptable from the viewpoint of recovery from transaction failure.
If T8 should abort, T9 would have read (and possibly shown to the user) an
inconsistent database state. Hence, database must ensure that schedules
are recoverable.
Schedule 12