The different aspects of transaction processing are discussed in this chapter. We will also review the low-level tasks, the transaction states and properties of a transaction used in a transaction. We will look at schedules and the serializability of schedules in the last portion.
A transaction is a program executed as a logical data processing unit, including a collection of database operations. One or more database operations, such as inserting , deleting, updating or retrieving data, include the operations performed in a transaction. It is an atomic process that is either fully finished or not carried out at all. A transaction that requires only retrieving data without changing any data is called a read-only transaction.
Each operation at a high level can be split into a number of tasks or operations at a low level. A data update operation can, for example, be split into three tasks-
read_item() − reads data item from storage to main memory.
modify_item() − change value of item in the main memory.
write_item() − write the modified value from main memory to storage.
Database access is restricted to read_item() and write_item() operations. Likewise, for all transactions, read and write forms the basic database operations.
The operations at low levels conducted in a transaction are-
A transaction which move through an active, partially committed, committed, failed and aborted sub-set of five states.
Any transaction must preserve the properties of ACID, viz. Atomicity, Consistency, Durability, and Isolation.
A schedule is the total order of execution of operations in a system with a number of simultaneous transactions. In view of the schedule S consisting of n transactions , i.e. T1, T2, T3 .......... Tn; for every Ti transaction, Ti transactions shall be executed as stated in schedule S.Types of Schedules
There are two kinds of schedules:
Serial Schedules − In a serial schedule, only one transaction is active at any point of time, i.e. there is no transaction overlap. This is seen in the following graph –
Parallel Schedules-More than one transaction is active simultaneously in parallel schedules, i.e. the transactions involve transactions that overlap at the time. This is seen in the following graph –
Conflicts in Schedules
A conflict occurs in a schedule consisting of several transactions when two active transactions execute non-compatible operations. If any of the following three conditions occur simultaneously, two operations are said to be in conflict.
A 'n' transaction serializable schedule is a parallel schedule similar to a serial schedule containing the same 'n' transactions. A serializable schedule requires the correctness of the serial schedule when deciding that the parallel schedule is used best by the CPU.Equivalence of Schedules
Two schedules may be equivalent to the following types: