DBMS Concepts

DBMS Tutorial Components of DBMS. Applications of DBMS The difference between file system and DBMS. Types of DBMS DBMS Architecture DBMS Schema Three Schema Architecture. DBMS Languages.

DBMS ER Model

ER model: Entity Relationship Diagram (ERD) Components of ER Model. DBMS Generalization, Specialization and Aggregation.

DBMS Relational Model

Codd’s rule of DBMS Relational DBMS concepts Relational Integrity Constraints DBMS keys Convert ER model into Relational model Difference between DBMS and RDBMS Relational Algebra DBMS Joins

DBMS Normalization

Functional Dependency Inference Rules Multivalued Dependency Normalization in DBMS: 1NF, 2NF, 3NF, BCNF and 4NF

DBMS Transaction

What is Transaction? States of transaction ACID Properties in DBMS Concurrent execution and its problems DBMS schedule DBMS Serializability Conflict Serializability View Serializability Deadlock in DBMS Concurrency control Protocols

Difference

Difference between DFD and ERD

Misc

Advantages of DBMS Disadvantages of DBMS Data Models in DBMS Relational Algebra in DBMS Cardinality in DBMS Entity in DBMS Attributes in DBMS Data Independence in DBMS Primary Key in DBMS Foreign Key in DBMS Candidate Key in DBMS Super Key in DBMS Aggregation in DBMS Hashing in DBMS Generalization in DBMS Specialization in DBMS View in DBMS File Organization in DBMS What Is A Cloud Database What Is A Database Levels Of Locking In DBMS What is RDBMS Fragmentation in Distributed DBMS What is Advanced Database Management System Data Abstraction in DBMS Checkpoint In DBMS B Tree in DBMS BCNF in DBMS Advantages of Threaded Binary Tree in DBMS Advantages of Database Management System in DBMS Enforcing Integrity Constraints in DBMS B-Tree Insertion in DBMS B+ Tree in DBMS Advantages of B-Tree in DBMS Types of Data Abstraction in DBMS Levels of Abstraction in DBMS 3- Tier Architecture in DBMS Anomalies in Database Management System Atomicity in Database Management System Characteristics of DBMS DBMS Examples Difference between Relational and Non-Relational Databases Domain Constraints in DBMS Entity and Entity set in DBMS ER Diagram for Banking System in DBMS ER Diagram for Company Database in DBMS ER Diagram for School Management System in DBMS ER Diagram for Student Management System in DBMS ER Diagram for University Database in DBMS ER Diagram of Company Database in DBMS Er Diagram Symbols and Notations in DBMS How to draw ER-Diagram in DBMS Integrity Constraints in DBMS Red-Black Tree Deletion in DBMS Red-Black Tree Properties in DBMS Red-Black Tree Visualization in DBMS Redundancy in Database Management System Secondary Key in DBMS Structure of DBMS 2-Tier Architecture in DBMS Advantages and Disadvantages of Binary Search Tree Closure of Functional Dependency in DBMS Consistency in Database Management System Durability in Database Management System ER Diagram for Bank Management System in DBMS ER Diagram for College Management System in DBMS ER Diagram for Hotel Management System in DBMS ER Diagram for Online Shopping ER Diagram for Railway Reservation System ER Diagram for Student Management System in DBMS Isolation in DBMS Lossless Join and Dependency Preserving Decomposition in DBMS Non-Key Attributes in DBMS Data Security Requirements in DBMS DBMS functions and Components What is Homogeneous Database? DBMS Functions and Components Advantages and Disadvantages of Distributed Database Relational Database Schema in DBMS Relational Schema Transaction Processing in DBMS Discriminator in DBMS

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]