×

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

Data Models in DBMS

Data Models in DBMS Data models are the models explaining the logical structure of the database systems. They describe the entities, attributes, and the relationship among the data elements of the...

8 minutes read.

Advantages of DBMS

A Database Management System (DBMS) is a collection of programs which lets the end-users to manage and control the database. Database systems use query language for accessing, storing, and maintaining the...

3 minutes read.

Conflict Serializability in DBMS

Conflict Serializability A schedule is said to be conflict serializable if it can transform into a serial schedule after swapping of non-conflicting operations. It is a type of serializability that can be used...

3 minutes read.

Components of Relational Database Management System

A relational database management system compromises various component. Tables, records, attributes, instances, schemas and keys together form a relational database. In this page, we will discuss each component of RDBMS in...

4 minutes read.

Evaluating DBMS

There are various database management systems available in the market. Each type has its features and can be used for varied purposes. The large number of DBMS makes it difficult...

4 minutes read.

Secondary Key in DBMS

What are Keys? Keys in DBMS are the attributes or set of attributes that uniquely identify a row in a set of relations. A table (relation) can have a column or...

3 minutes read.

Disadvantages of DBMS

Disadvantages of DBMS With the vast list of advantages, there are some following disadvantages or limitations of the database management system. 1. High Cost The high cost of software and hardware is the...

2 minutes read.

Levels of Abstraction in DBMS

Data abstraction is a way to hide unwanted or irrelevant information from the end user in DBMS. It helps in enhancing the security of data, and simplifies database design using...

4 minutes read.

Disavantages of RDBMS

RDBMS offers many features when handling the data, but it also has certain limitations that can be overcome by choosing an alternative data model. The limitations of the Relational Data...

3 minutes read.

DBMS Schedule

A schedule is a process of combining the multiple transactions into one and executing the operations of these transactions in a predefined order. A schedule can have multiple transactions in it, each transaction...

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.

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.

ER Diagram for School Management System in DBMS

What is ER Diagram? An ERD, or entity relationship diagram, is a diagram that depicts the connections between a group of entities contained in a database. In other words, ER diagrams...

6 minutes read.

Foreign key in DBMS

Foreign key in DBMS: The Foreign key is a field or the set of fields in the relational database table, which points to the existing field in another table. It...

2 minutes read.

Aggregate Functions in DBMS

Aggregate Functions in DBMS: Aggregate functions are those functions in the DBMS which takes the values of multiple rows of a single column and then form a single value by...

2 minutes read.

DBMS Generalization, Specialization, and Aggregation

DBMS Generalization Generalization is a bottom-up approach in which the common attributes of two or more lower-level entities combines to form a new higher-level entity. In generalization, the generalized entity of higher level can also...

3 minutes read.

Anomalies in Database Management System

Anomalies in a database management system (DBMS) are problems that can arise when the database is not designed or implemented correctly. These anomalies can affect the integrity and accuracy of...

3 minutes read.

Difference between DBMS and RDBMS

Database Management System A DBMS is system software which is used to store and manage the data in the database. It was introduced in 1960 for storing the data or information. This system allows...

3 minutes read.

Specialization in DBMS

Specialization in DBMS In the database management system, specialization breaks the higher-level entity into two or more than two lower entities. The main motive of this concept is to share the...

2 minutes read.

Query processing in DBMS

Operations on DBMSs are made much simpler, more organized, and methodical with SQL. These are not only simpler for people to comprehend, but after gaining a basic comprehension of them, they...

4 minutes read.