0% completed
Atomicity is one of the core ACID properties that ensure the integrity of a database during transactions. It guarantees that each transaction is executed as a single, indivisible unit of work. This means a transaction will either complete all of its operations successfully or fail entirely, leaving the database unchanged.
Without atomicity, partial updates can leave the database in an inconsistent state, resulting in corrupted or incorrect data.
In the above example, there are two accounts, A and B:
Initial State:
Transaction Process:
Final State:
Problem: Partial execution violates atomicity. The $10 is debited from A, but not credited to B. This leads to data inconsistency.
Databases implement atomicity through mechanisms like transaction logs, shadow copies, and recovery protocols. One of the simpler implementations of atomicity is the Shadow Copy technique.
Shadow Copy is a technique where the database ensures atomicity by creating a separate copy of the database file for every transaction. Here’s how it works:
Successful Transaction:
Failure in Pointer Update:
Failure During Execution:
While shadow copy was an early implementation, modern databases achieve atomicity more efficiently using:
Atomicity ensures:
.....
.....
.....