0% found this document useful (0 votes)
10 views2 pages

Acid

Uploaded by

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

Acid

Uploaded by

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

1.

Atomicity

• Definition: Atomicity refers to the all-or-nothing nature of a transaction. It ensures that a


transaction is treated as a single, indivisible unit. Either all operations within the transaction
are completed successfully, or none of them are.

Key Point: If a transaction involves multiple operations (e.g., inserting data into multiple tables), and
one of those operations fails, the entire transaction is rolled back. No partial updates are made to the
database.

Example:

o Imagine a bank transfer from one account to another. The transaction involves two
steps:

1. Deducting the amount from Account A.

2. Adding the amount to Account B.

If the first step succeeds but the second step fails (due to a system crash), the atomicity property
ensures that the transaction is rolled back, and neither account is modified. This prevents the
situation where money is deducted from one account but not credited to the other.

2. Consistency

• Definition: Consistency ensures that a database transitions from one valid state to another
after a transaction is completed. The database must always adhere to its rules, constraints,
and relationships, and must not violate any integrity constraints.

Key Point: A transaction will bring the database from one consistent state to another consistent
state, even if the transaction involves multiple operations. The integrity constraints (such as primary
keys, foreign keys, etc.) are preserved, and the database should always remain in a valid state.

Example:

o In a banking system, if an account balance should never be negative, a transaction


that withdraws more money than the available balance would violate the
consistency rule. The transaction would not proceed and would be rolled back.

3. Isolation

• Definition: Isolation ensures that the operations of one transaction are isolated from those
of other concurrent transactions. Even if multiple transactions are executing at the same
time, the intermediate steps of one transaction should not be visible to others until the
transaction is fully completed.

Key Point: Isolation prevents "dirty reads," "non-repeatable reads," and "phantom reads." In other
words, a transaction should not see the intermediate, uncommitted changes made by other
transactions that are running concurrently.

Example:
o Consider two users transferring money at the same time from the same account.
Without proper isolation, one transaction might see an intermediate balance before
it has been updated by the other transaction. This could lead to errors such as
overdrawing an account.

Isolation Levels:

o SQL databases support different isolation levels (e.g., Read Uncommitted, Read
Committed, Repeatable Read, Serializable) that define the degree to which
transactions are isolated from each other.

4. Durability

• Definition: Durability ensures that once a transaction has been committed (i.e., successfully
completed), its changes to the database are permanent, even in the case of a system crash,
power failure, or other unexpected events.

Key Point: After a transaction is committed, the database will persist the changes, and they cannot
be undone. The data remains stable and consistent even if the system encounters a failure.

Example:

o If a transaction commits a record of a bank transfer, that transaction will be


permanent. Even if the system crashes immediately after the commit, the changes
(such as the updated account balances) will persist in the database once the system
restarts.

Importance of ACID Properties:

• Reliability: ACID properties ensure that transactions are reliable and that the database
system will work correctly even in the event of errors or system failures.

• Data Integrity: They maintain the integrity and correctness of the database, ensuring that
the data remains consistent and accurate.

• Concurrency Control: ACID properties, especially isolation, are essential for handling
multiple concurrent users and transactions, making sure they don't interfere with each other.

• Durability: Guarantees that critical business data is not lost, even in the case of unforeseen
events like system crashes.

In conclusion, the ACID properties are fundamental for the proper functioning of a relational
database system, ensuring that the data remains accurate, reliable, and consistent even in complex
scenarios involving multiple concurrent transactions.

You might also like