0% found this document useful (0 votes)
3 views

ACID Properties

ACID properties in SQL ensure reliable transaction processing by enforcing Atomicity, Consistency, Isolation, and Durability. These principles maintain data integrity and consistency, especially in multi-user environments, by ensuring transactions are treated as indivisible units, that databases remain in valid states, and that changes persist even after failures. Practical examples include bank transactions and e-commerce order processing, highlighting the importance of ACID compliance in preventing data corruption and supporting concurrent transactions.

Uploaded by

vivek4chougule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

ACID Properties

ACID properties in SQL ensure reliable transaction processing by enforcing Atomicity, Consistency, Isolation, and Durability. These principles maintain data integrity and consistency, especially in multi-user environments, by ensuring transactions are treated as indivisible units, that databases remain in valid states, and that changes persist even after failures. Practical examples include bank transactions and e-commerce order processing, highlighting the importance of ACID compliance in preventing data corruption and supporting concurrent transactions.

Uploaded by

vivek4chougule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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

1|Page Learning Document w w w. s i m d a a . co m


3. Isolation
 Definition: Ensures that transactions are executed independently without interference
from other transactions.
 Explanation:
o Even when multiple transactions occur simultaneously, their intermediate
states should not be visible to each other.
o Isolation levels in SQL help control how and when changes made by one
transaction become visible to others.
 Isolation Levels:
o Read Uncommitted: Transactions can see uncommitted changes of others.
This is the least isolated level and may lead to "dirty reads."
o Read Committed: Ensures no dirty reads. A transaction can only see
committed changes.
o Repeatable Read: Prevents dirty and non-repeatable reads. However,
"phantom reads" (new rows being added) may occur.
o Serializable: The highest isolation level, ensuring complete isolation.
Transactions are executed sequentially, avoiding dirty reads, non-repeatable
reads, and phantom reads.
4. Durability
 Definition: Ensures that once a transaction is committed, its changes are permanently
stored in the database, even in the event of a system failure.
 Explanation:
o Durability is achieved through mechanisms like write-ahead logging,
transaction logs, and backups.
o The database ensures that committed data is written to non-volatile storage
(e.g., disk) before acknowledging the transaction completion.
 Example:
o If a power failure occurs immediately after a COMMIT, the database ensures
that the changes are recoverable using transaction logs.

2|Page Learning Document w w w. s i m d a a . co m


Practical Examples of ACID Properties
1. Bank Transactions:
o Atomicity: Deducting money from one account and adding it to another
should either both occur or neither.
o Consistency: Account balances should remain consistent, adhering to rules
like "total money in the system cannot change."
o Isolation: Simultaneous transfers shouldn't affect each other's intermediate
states.
o Durability: Once the transfer is confirmed, it should persist, even if the server
crashes.
2. E-commerce Order Processing:
o Atomicity: Either the order is placed, inventory is updated, and payment is
processed, or nothing happens.
o Consistency: Ensures inventory levels and user balances are correct.
o Isolation: Multiple users placing orders shouldn’t interfere with each other.
o Durability: Confirmed orders should persist despite failures.

Benefits of ACID Compliance


 Prevents data corruption.
 Maintains data integrity and reliability.
 Supports concurrent transactions in a safe manner.
 Essential for mission-critical systems like banking, healthcare, and finance.

3|Page Learning Document w w w. s i m d a a . co m


SUMMERY –
Atomicity –
The entire transaction takes place at once or doesn’t happen at all
Consistency –
The database must be consistent before and after the transaction.
Isolation –
Multiple transactions occur independently without interference
Durability –
The changes of a successful transaction occurs even if the system failure occurs.

4|Page Learning Document w w w. s i m d a a . co m

You might also like