2. WHAT IS TRANSACTION?
A transaction is a set of changes that must all be
Collection of operations that form a single logical
unit of work are called TRANSACTIONS.
A database system must ensure proper execution
of transactions deplete failures.
It must manage concurrent execution of
transactions to avoid inconsistency.
3. A transaction is a unit of program execution that accesses
and possibly updates various data items. A program
contains statements of the form begin transaction and
end transaction. The transactions consists of all
operations executed between the begin transaction and
Execution of transaction
(In between its execution, database may be
in inconsistent state)
4. TRNSACTION CONCEPT
A transaction accesses data with a series of Read
and Write operations.
Read operation : Reading of a database object
means that it is, firstly, brought into main memory
from the disk and then its value is copied into a
program variable i.e.,
Main memory Program Variableto
5. Similarly, during write operation, copy of the object is
first modified and then written to disk.
Main memory Diskto
Example: Let T be a transaction that transfers $50 from account A
to account B. This transaction can be defined as:
T : read(A)
6. PROPERTIES OF TRANSACTION
There are four important properties of transaction(ACID):
Atomicity : A transaction is said to be atomic if a
transaction always executes all of its action in one step
or not execute any actions at all.
It implies that either all or none of the transaction’s
operations are performed.
7. Consistency : A transaction must preserve the
consistency of a database after its execution. It means
that the execution of a transaction must leave a
database in either its prior stable state or new stable
If a transaction fails then the database must be
returned to its previous state.
If it is successful then the database must reflect new
8. Isolation : It means that the data used during the
execution of a transaction cannot be used by a second
transaction until the first one is completed.
The transactions do not interfere with each other. They
must behave as if they are executed in isolation.
This isolation property of a transaction is used in
multiuser database environments.
9. Durability : The effect of a completed or
committed transaction should persist even after
a system’s failure (crash).
It means that once a transaction commits, the
system must guarantee that result of its
operations will never be lost.
It is the responsibility of the recovery subsystem
10. S.No. Property Meaning
1. Atomicity All or nothing
2. Consistency No violation of integrity
3. Isolation Concurrent changes invisible
4. Durability Committed update persist.
So, we can say that:
12. Active state: It is the initial state. The transaction stays
in this state while it is executing.
Partially committed state: When the final statement
has been executed, we say, transaction is in partially
Failed state: When the normal execution can no longer
proceed, we say that the transaction is in a failed state.
Aborted state: A transaction is aborted if the
transaction has been rolled back and the database has
been restored to its state prior to the start of the
Committed state: When a transaction has successfully
13. Explanation:- A transaction starts in the active state.
When it finishes its last statement, it enters the
partially committed state. At this time, the
transaction has completed its execution but it is still
possible that it may have to be aborted as the actual
output may still be temporarily residing in the main
memory. DBMS then writes information to disk that
even if the system failure occurs, the update
performed by T can be recreated when the final or last
of this information is written out, the transaction
enters the committed state.