A transaction, in the context of a database, is a logical unit that is independently executed for data retrieval or updates. In relational databases, database transactions must be atomic, consistent, isolated and durable--summarized as the ACID acronym.
- Because failure of transaction may occur, transaction is broken up into states to handle various situations.
- Following are the different states in transaction processing in database
- Acitve
- Partial committed
- Failed
- Aborted
- Committed
(States of Transaction)
Active
- This is the initial state. The transaction stay in this state while it is executing.
Partially Committed
- This is the state after the final statement of the transaction is executed.
- At this point failure is still possible since changes may have been only done in main memory, a hardware failure could still occur.
- The DBMS needs to write out enough information to disk so that, in case of a failure, the system could re-create the updates performed by the transaction once the system is brought back up.
- After it has written out all the necessary information, it is committed.
Failed
- After the discovery that normal execution can no longer proceed.
- Once a transaction cannot be completed, any changes that it made must be undone rolling it back.
Aborted
- The state after the transaction has been rolled back and the database has been restored to its state prior to the start of the transaction.
Committed
- The transaction enters in this state after successful completion of the transaction.
- We cannot abort or rollback a committed transaction.