Transactions
Transactions
TRANSACTIONS
Single and Multiusers Database
Classifying a database system according to the number of users who can
use the system concurrently:
1. single-user
only a single user can access the database. Hence, the user can use all the resources
at all times.
2. multi-user database systems.
These DBMSs support two or more two users accessing the database
simultaneously. Multiple users can update data while working together
simultaneously.
• Suppose T has been executed till Read (Y) and then T’’ starts.
As a result, interleaving of operations takes place due to
which T’’ reads the correct value of X but the incorrect value of Y
and sum computed by :
T’’: (X+Y = 50, 000+500=50, 500)
is thus not consistent with the sum at end of the transaction:
T: (X+Y = 50, 000 + 450 = 50, 450).
Durability
• This property ensures that once the transaction has completed
execution, the updates and modifications to the database are stored
in and written to disk and they persist even if a system failure occurs.
• for any transaction Ti, the operations in Ti must execute as laid down in the
schedule S.
Types of Schedules
• There are two types of schedules −
1- Serial Schedules − In a serial schedule, at any point of time, only
one transaction is active, i.e. there is no overlapping of transactions.
Types of Schedules
• For example: Suppose there are two transactions T1 and T2 which have some
operations. If it has no interleaving of operations, then there are the following two
possible outcomes:
1. Execute all the operations of T1 which was followed by all the operations of T2.
2. Execute all the operations of T2 which was followed by all the operations of T1.
Types of Schedules
• 2- Parallel Schedules − In parallel schedules, more than one transactions are
active simultaneously, i.e. the transactions contain operations that overlap at time.
Serializable schedule
• The serializability of schedules is used to find non-serial schedules
that allow the transaction to execute concurrently without interfering
with one another.
• It identifies which schedules are correct when executions of the
transaction have interleaving of their operations.
• A non-serial schedule will be serializable if its result is equal to the
result of its transactions executed serially.
Testing of Serializability
• Serialization Graph is used to test the Serializability of a schedule.
• This graph has a pair G = (V, E), where V consists a set of vertices, and E consists
a set of edges.
• The set of vertices is used to contain all the transactions participating in the
schedule.
• The set of edges is used to contain all edges Ti ->Tj for which one of the three
conditions holds:
1 Create a node Ti → Tj if Ti executes write (Q) before Tj executes read (Q).
2 Create a node Ti → Tj if Ti executes read (Q) before Tj executes write (Q).
3 Create a node Ti → Tj if Ti executes write (Q) before Tj executes write (Q).
Testing of Serializability
• If a precedence graph contains a single edge Ti → Tj, then all the instructions
of Ti are executed before the first instruction of Tj is executed.
Contains cycles
Not Serializable
Testing of Serializability (example 2)
Acyclic Graph
Serializable