Chapter 3 ADBMS
Chapter 3 ADBMS
Reading Ass:
Discuss on Advantages and disadvantages of both processes?
Introduction to Transaction Processing
Types of Transaction
Read-only transaction: A transaction operation that do not update the database but only retrieve data
from the database.
Read-Write transaction: A transaction operation that perform the update operation in addition to
retrieval of database data.
For transaction processing purposes, a simple database model is used:
• A database - collection of named data items
• Granularity (size) of a data item - a field (data item value), a record, or a whole disk block
– TP concepts are independent of granularity
A transaction is an atomic unit of work that is either completed in its entirety or not done
at all.
For recovery purposes, the system needs to keep track of when each transaction starts,
terminates, and commits or aborts.
A transaction passes through several states (see figure in the next slide).
Transaction states:
Active state (executing read, write operations/beginning of transaction execution)
Partially committed state (ended but waiting for system checks to determine success
or failure/not ensure permanent modification on DB.)
It is only saved on buffer/temporary memory.
Committed state (transaction succeeded/changes done persistently)
Failed state (transaction failed, must be rolled back/aborted during active state or if
one rechecking is fails.)
Terminated State (transaction leaves system)
Transaction and System Concepts
Transaction and System Concepts (cont.)
DBMS Recovery Manager needs system to keep track of the following operations
(in the system log file):
• Begin_transaction: beginning of transaction execution.
• Read or write: Read or write operations on the database items that are executed
as part of a transaction.
• End_transaction: Specifies end of read and write transaction operations have
ended.
• System may still have to check whether the changes (writes) introduced by
transaction can be permanently applied to the database (commit transaction);
or whether the transaction has to be rolled back (abort transaction) because it
violates concurrency control or for some other reason.
Transaction and System Concepts (cont.)
Transactions should possess several properties, often called the ACID properties – Atomicity,
Consistency, Isolation, Durability:
► Atomicity: A transaction is an atomic unit of processing; it is either performed in its
entirety or not performed at all.
► Atomicity involves the following two operations:
► Abort: If a transaction aborts then all the changes made are not visible.
► Commit: If a transaction commits then all the changes made are visible.
► Consistency : A correct execution of the transaction must take the database from one
consistent state to another.
– The integrity constraints are maintained so that the database is consistent before and
after the transaction.
– The execution of a transaction will leave a database in either its prior stable state or a
new stable state.
Desirable Properties of Transactions (cont.)
Conflict of Schedule
• Two operations in a schedule are said to conflict if they satisfy all three of the following
conditions:
1. They belong to different transactions
2. They access the same item X and
3. At least one of the operations is a write_item(X).
• The rest of this section covers some theoretical definitions concerning schedules.
• A schedule S of n transactions T1, T2, ..., Tn is said to be a complete schedule if
the following conditions hold:
1. The operations in S are exactly those operations in T1,T2,...,Tn, including a
commit or abort operation as the last operation for each transaction in the
schedule.
2. For any pair of operations from the same transaction T i, their relative order of
appearance in S is the same as their order of appearance in T i.
3. For any two conflicting operations, one of the two must occur before the
other in the schedule.
• Rest of chapter characterizes schedules by classifying them based on ease of
recovery (recoverability) and correctness (serializability)
Characterizing Schedules based on Recoverability
Practical approach:
• Come up with methods (concurrency control protocols)
to ensure serializability (discussed in Chapter 6)
• DBMS concurrency control subsystem will enforce the
protocol rules and thus guarantee serializability of
schedules
• Current approach used in most DBMSs:
– Use of locks with two phase locking (see chpter 6)
Characterizing Schedules based on Serializability (cont.)
Testing for conflict serializability Algorithm
• Looks at only r(X) and w(X) operations in a schedule
• Constructs a precedence graph (serialization graph) – one
node for each transaction, plus directed edges
• An edge is created from Ti to Tj if one of the operations in Ti
appears before a conflicting operation in Tj
• The schedule is serializable if and only if the precedence graph
has no cycles.
Characterizing Schedules based on Serializability (cont.)
End of Chapter
Thank You!