Explain ACID properties of transaction.
In : BE Subject : Database Management Systemsa transaction is a single logical unit of work that consists of one or more database operations such as insert, update, delete, or retrieve. To ensure that the database remains correct and reliable even in the presence of failures or concurrent execution, every transaction must satisfy the ACID properties.
-
Atomicity – This property ensures the “all-or-nothing” nature of a transaction. Either all operations within the transaction are executed successfully, or none of them are reflected in the database. If a failure occurs in the middle of execution, all partial changes are rolled back, leaving the database unchanged. For example, in a money transfer transaction, if the debit is successful but the credit fails, the debit must also be undone.
-
Consistency – A transaction must take the database from one consistent state to another consistent state, while preserving all integrity constraints such as primary keys, foreign keys, and business rules. This ensures that invalid data is not introduced into the system during execution.
-
Isolation – This property ensures that transactions executing concurrently do not interfere with each other. Each transaction should execute as if it were running alone, independent of others. For instance, if two users are booking the last seat in a train at the same time, isolation ensures that only one succeeds and the database does not end up in an inconsistent state.
-
Durability – Once a transaction has been committed, its effects are permanent in the database, even in the case of system crashes or power failures. This is typically achieved by maintaining logs and using recovery techniques.