This topic we shall learn about ACID properties.
In this chapter we shall study about what is ACID properties of a transaction and why it is important.
11.1 ACID stands for
11.2 Need for ACID properties?
Whenever we need to read or write into DB we need the data to be consistent and we want to maintain it consistent.
11.3 How do we maintain the consistency of the data?
We know that, a transaction is sequence of instructions to update a data in DB. Instead of making the DB to be consistent, we can make the transactions to be consistent in turn making DB to be consistent. Hence if a transaction satisfies the ACID properties, then it will maintain consistency. Hence to make a transaction to be consistent, the transaction should follow ACID properties.
Let us understand in brief about these 4 properties:
This is the basic property of a transaction. It states that either all the instructions should execute or none of them are executed. This make sense because, if only partial sequence of instructions are executed, then the data will not be consistent.
This property states if the DB that is consistent state say D1. Then you change change the database state by running a transaction T1. Now the database state will be in state D2. Then according to the consistency property as D1 was in consistent state, hence D2 should also be in consistent state.
Consider 2 transaction T1 and T2, we say that these 2 transactions are in isolation with each other if they are not effected by each other.
This property states if you have made any changes to the data, that data should be present irrespective of hardware or software failure.
Hence if a transaction satisfies Atomicity Isolation and Durability, then the consistency can be easily achieved.
11.8 What is a transaction?
A transaction is a series of instructions carried out by a single user, that is used to read or update the contents of the database. Once the transaction is completed the DB will reach to a new consistent state. There is an option to rollback the transaction.
11.9 What are the States of Transaction?
Active: When you start a transaction, it will be in active state. It will remain in active state till you perform read or write operation.
Partially Committed: Once the transaction is near to end, it will be in partially committed state.
Committed: From the partially committed state, once you commit the transaction, it will be in committed state. Then that transaction will be in terminated state.
Failed: Failed state can be reached from Active or Partially committed state. During active state or Partially Committed, if you click on abort operation then it will go to failed state.
Terminated: Terminated state can be reached from Committed or Failed state. This is the final state for any transaction. If any transaction reached this state, it means the transaction cycle has ended.