ACID Properties
ACID Properties
In SQL, ACID properties are a set of principles that ensure reliable transaction processing in
a database. They play a critical role in maintaining the integrity and consistency of data,
especially in multi-user and distributed environments.
ACID Properties
1. Atomicity
2. Consistency
3. Isolation
4. Durability
1. Atomicity
Definition: Ensures that a transaction is treated as a single, indivisible unit of work. It
either completes entirely or does not occur at all.
Explanation:
o A transaction may involve multiple operations (e.g., updating multiple rows or
tables).
o If any part of the transaction fails (e.g., due to a power failure or an error), the
entire transaction is rolled back to its initial state.
2. Consistency
Definition: Ensures that a database remains in a valid state before and after a
transaction. The transaction must transform the database from one consistent state to
another.
Explanation:
o Consistency enforces rules such as constraints, triggers, and referential
integrity.
o If a transaction violates these rules, it will be aborted.
Example:
o Suppose a CHECK constraint ensures that account balances cannot go
negative. If a transaction tries to withdraw more money than available, it will
fail to maintain consistency