What is a Transaction in DBMS ?

A Transaction is a logical unit of work. It is the set of operations( basically read and write) to perform unit of work,( include small units of work).

It can be viewed as a program whose execution preserves the consistency of the database. The primary goal of concurrency control and recovery scheme is to ensure that the execution of a transaction be atomic. What it means is, each transaction should access shared data without interfering with the other transactions and whenever a transaction successfully completes its execution, its effect should be fine lover, sales to complete(e.g. system failure), it should not have any effect on the student database.

Transaction which successfully completes its execution is said to have been committed, otherwise the transaction is aborted or rollback. Bus if a committed transaction performance any update operation on the database, its effect must be reflected on the database even if there is a failure.

Some Points related to Transaction :

Transaction processing in a single and multi user environment

Single user : DBMS is a single user at most one user using the system.

Multi user : DBMS is a multi-user if many users are using the system concurrently/simultaneously. For example, banking system or an Airline reservations.

Processing in multi user environment

Multiple users can access the database using the concept of multiprogramming, which allows OS to execute multiple program or processes at the same time. If a process waiting for IO transfer there is another program heading to utilise the CPU. So it is possible to share the time of the CPU for the several jobs. The process which is suspended is resumed from the point where it was suspended. Hence, concurrent execution of processes is actually interleaved which is illustrated in figure. There are two processes P1 and P2 executing concurrently in an interleaved fashion.

If there are multiple CPUs, then parallel processing of multiple processes is possible which is illustrated in figure. There are two processes p3 and P4 which are executing parallely because of different CPUs.

Boundaries of a transaction :
  • Begin Transaction/ Start
  • End Transaction / End

We can specify explicitly the boundaries of a transaction by begin transaction and end transaction statements in an application program.
A single application program may contain more than one transaction if it contains several transaction boundaries.

Types of transaction :

Read only transaction : If the database operations in a transaction do not update the database but only retrieve data.

Read write transaction : If the database operation in a transaction retrieves as well as update the database.

Why Recovery is Needed and The Operations of a Transaction:

Whenever a transaction is executing, either it must complete all the operations in the transaction and their changes must be permanently saved or the transaction does not have any effect on the database or any other transactions. So, for recovery purpose, the recovery manager of the DBMS needs to keep track of the following operations :

  1. Begin Transaction / Start : It marks the beginning of transaction execution.
  2. Read (A) : Reads a data item named A into a program variable.
  3. Write(A) : Updation of  data item (A) into database.
  4. Commit : Transaction completed successfully.
  5. End Transaction / End : It marks the end of transaction execution.
  6. Rollback : It signals that the transaction has ended unsuccessfully, and so, any changes that the transaction may have applied to the database must be undone.

Steps involves in Execution of Transaction :

Database is represented as a collection of named data items. The data item can be a single database record or multiple database record or a field in a database record. The size of the data item is called its granularity.
Process involves in execution of transaction - What is a Transaction in DBMS ?

States of a transaction :

A Transaction can be in one of the following states :

  1. Active: After the transaction has issued its start or say the transaction starts execution.
  2. Partially committed : When the last statement is reached i.e. when the transaction ends.
  3. Aborted or rollback : If it is found that normal execution can no longer be performed.
  4. Committed : After successful completion.
  5. Failed : If any failure occurs.
  6. Terminated : Either the transaction is successfully completed or it is aborted.

Following figure shows a state transition diagram that illustrates how a transaction moves through its execution states.

States of Transaction - Transaction in DBMS

Problems of Transaction and How to Solve them ??:

Transaction is associated with the following 3 problems :

  • It may create an inconsistent results.
  • It may create problems in concurrent execution.
  • It may create an uncertainty to decide when to make changes permanent.
How to solve the above 3 problems ?

To solve the above 3 problems, we have defined some properties for the transactions and they are called ACID properties.

  1. A – Atomicity
  2. C – Consistency
  3. I – Isolation
  4. D – Durability

If any transaction satisfies these properties, then we can say it will be free from about problems.

CLICK To Know About ACID Properties.

Previous Home Next
Relational Calculus with some Quetions ACID Proprties


Incoming search terms:

  • transaction in dbms
  • what is transaction in dbms
  • types of transaction in dbms
  • states of transition edugrabs
  • transactions edugrabs
  • transactions types edugrabs

Leave a Reply