What is a transaction? And what are ACID properties?- Transaction is a sequence of SQL commands.
- Transaction encapsulates SQL commands and work as a single unit.
- All the SQL statements defined in the transaction should work successfully.
Every transaction follows ACID properties:
1. A - Atomicity 2. C - Consistency 3. I - Isolation 4. D - Durability
- Transaction ensures that certain characteristics. These characteristics are known as ACID properties.
1. Atomicity:
- It identifies that the transaction is atomic. - It is either fully completed, or not begun at all. - If for any reason an error occurs and the transaction is unable to complete its steps, then the system is returned to the state before the transaction was started.
2. Consistency:
- It ensures that any transaction will bring the database from one valid state to another. - It ensures that any changes to values in an instance are consistent with changes to other values in the same instance.
3. Isolation:
- It ensures that the concurrent execution of transactions results in a system state. - Providing isolation is the main goal of concurrency control. - It is needed when there are concurrent transactions.
4. Durability:
- It ensures that once a transaction has been committed, it will remain so, even in the event of power loss, errors or crashes. - It maintains the updates of committed transaction is critical. - It refers to the ability of the system to recover committed transaction updates if the system or the storage media fail.
|