×

States of Transaction in DBMS

Transaction States

A transaction passes through many different states in its life cycle. These states are known as transaction states. A transaction can be in one of the following states in the database:

  1. Active state
  2. Partially committed state
  3. Committed state
  4. Failed state
  5. Terminated state

Active State

This is the first state in every transaction life cycle. A transaction is said to be in an active state when it starts execution and performs read and write operations.

Partially committed state

This state is also an execution phase. Any transaction enters into this state when the final operation of the transaction gets executed, but the data is still not saved to the database.

Committed state

Any transaction enters in committed state when all the operations of transaction are completed successfully. And all the changes made by the transaction are permanently saved into the database.

Failed state

Any transaction is entered in this state when the normal execution of it can no longer proceed. Or we can say that, if any transaction cannot proceed to the execution phase due to system failure, then the transaction is said to be in a failed state.

Aborted state

Any transaction is said to be in an aborted state when a transaction fails in its execution and goes into a failed state. And all the changes made by the transaction has to be rolled back to the previous consistent state.

Terminated State

Any transaction reaches terminated state when a specific transaction which is leaving the system can't be restarted. After the transaction is committed successfully or rollback due to system or database failure, finally it indicates the transaction is over.

Example:

Let’s suppose a transaction T through which you want to transfer 100Rs from account ‘X’ (source account) to account ‘Y’ (destination account). Assume that the account balance of X is 500 and Y is 1000. This transaction T can be represented as:

Transaction T
BEGIN TRANSACTION
Read(X);   …..(1)
X=X-50;  …..(2)
Write(X);  …..(3)
Read(Y);   …..(4)
Y=Y+50;     …..(5)
Write(Y);    …..(6)
Commit;    …..(7)
END TRANSACTION

ACTIVE: When the above transaction T starts, i.e., enters BEGIN TRANSACTION, the transaction in an active state. From BEGIN TRANSACTION and COMMIT statement, the transaction is in the ACTIVE state only.

In an ACTIVE state, value of X= 500 and value of Y = 1000.

PARTIALLY COMMITTED: If T transaction reaches the statement COMMIT, it goes into partially committed state.

In PARTIALLY COMMITTED state, X= 400 and Y= 1100;

FAILED: This state happens if one of the following occurs:

If any system or database failure happens to the transaction in an ACTIVE state, then the transaction goes into an FAILED state.

  • If the transaction failed before Write(X), then X = 500 and Y = 1000. 
  • If the transaction failed after Write(X), then X= 400 and Y = 1000. 
  • If the transaction failed before Commit and after WRITE(Y)statement, then X = 400 and Y = 1100.
  • If any failure happen to the above transaction T in a partially committed state, then the transaction goes into the failed state, the value of X is 500, and Y is 1000.

ABORTED: In an aborted state, X= 500 and Y= 1000. [X and Y both are rolled back to Old consistent state]

COMMITTED: If above transaction T executes COMMIT statement successfully. In other words, if it successfully writes the new value of X and Y into the database or a log file, then the transaction is said to be in a committed state.

In COMMITTED state, X = 400 and Y = 1100. [New consistent state]


Related Topics

Advantages of B-Tree in DBMS

A self-balancing search tree is the B-Tree. It is assumed that everything is in the main memory in most other self-balancing search trees (such as AVL and Red-Black Trees). We must...

3 minutes read.

DBMS Architecture

Architecture of Database Management System DBMS architecture helps in development, implementation, design, and maintenance of a database that store and organize information for agencies, businesses, and institutions. It is the base of any database...

2 minutes read.

Cardinality in DBMS

Cardinality in DBMS Cardinality is the relationship between two or more entities (table). It shows how all the entities are connected. In DBMS, all the entities and tables are interconnected with...

2 minutes read.

Er Diagram Symbols and Notations in DBMS

Entity Relationship Diagram Entity Relationship Diagrams, or ER Diagrams for short, are diagrams that show the relationships among entity sets that are stored in databases. Alternatively said, ER diagrams assist in...

6 minutes read.

Meta Data in DBMS

Metadata: Metadata is simply described as information about information. It indicates that the data is described as well as its context. It makes data easier to find, interpret, and organize. I'll...

4 minutes read.

Schedule in DBMS

Schedule A sequence of statements that specify the sequential order in which the statements of concurrent transactions are executed. The transaction will get committed when it executes the instructions successfully without any...

4 minutes read.

Deadlock in DBMS

Deadlock in DBMS A deadlock is an unwanted condition in which two or more transaction are waiting indefinitely for one another to give up locks. It is said to be one of the...

3 minutes read.

States of Transaction in DBMS

Transaction States A transaction passes through many different states in its life cycle. These states are known as transaction states. A transaction can be in one of the following states in the database: Active statePartially...

3 minutes read.

Advantages of Threaded Binary Tree in DBMS

We know that every node in a binary tree contains both its data value and the address pointers for its left and right children. A null pointer is used to...

3 minutes read.

Concurrent Execution of Transaction

In the transaction process, a system usually allows executing more than one transaction simultaneously. This process is called a concurrent execution. Advantages of concurrent execution of a transaction Decrease waiting time or...

4 minutes read.

Serializability in DBMS

Serializability in DBMS Serializability is the concept in a transaction that helps to identify which non-serial schedule is correct and will maintain the database consistency. It relates to the isolation property of transaction in...

3 minutes read.

How to draw ER-Diagram in DBMS?

Entity Relationship Diagrams, or ERDs, are diagrams that assist you in visualizing your database design. An ERD, also called anER diagram or ER model,describes data and how parts of the data interact. ERDs are crucial in database architecture and projects that call for...

9 minutes read.

Fragmentation in Distributed DBMS

Fragmentation is a course of isolating the entire or full information base into different sub tables or sub relations with the goal that information can be put away in various...

4 minutes read.

What is RDBMS?

To discuss the Relational Database Management System, there are some terms and concepts you need to know. Database Any collection of related information is called a database. The phone book is...

5 minutes read.

ER Diagram for Student Management System in DBMS

Entity Relationship diagrams Entity Relationship Diagrams, or ER Diagrams for short, are diagrams that show the relationships among entity sets that are stored in databases. Alternatively said, ER diagrams assist in...

6 minutes read.

DBMS Joins: Inner, Outer, Natural and Self Join

Joins are the combination of related tuples from the two different relations or tables into a single type. It is similar to the Cartesian product except the fact that in Cartesian product operation,...

4 minutes read.

Super Key in DBMS

Super Key in DBMS: The super key is a column or a set of columns in the database table, which uniquely identifies the tuple or row of the same table....

2 minutes read.

DBMS Examples

Introduction to DBMS A database management system (DBMS) is a software application that is designed to manage and organize data stored in a database. It is responsible for storing, retrieving, and...

4 minutes read.

Inference Rules

Armstrong’s axioms are the complete set of basic inference rules used to infer all the functional dependencies on the relational database. An inference rule is a type of assertion that a user can...

2 minutes read.

Red-Black Tree Deletion in DBMS

Introduction To Red Black Tree Each node's extra bit in a red-black tree, a type of self-balancing binary search tree, is frequently understood as the color (red or black). The balance...

3 minutes read.