0% found this document useful (0 votes)
21 views9 pages

ACID in DBMS

ACID in DBMS

Uploaded by

lagishetti
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)
21 views9 pages

ACID in DBMS

ACID in DBMS

Uploaded by

lagishetti
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/ 9

ACID Properties in DBMS

Understanding Atomicity, Consistency, Isolation,


and Durability
Transaction :
 A Transaction in a DBMS is a sequence of operations performed as a
single logical unit of work. A transaction must follow the ACID properties
(Atomicity, Consistency, Isolation, Durability) to ensure data integrity and
consistency.
Key Points of a Transaction:
 A transaction begins when a user performs an operation (e.g., inserting,
updating, deleting records).
 It ends with either a commit (successful completion) or a rollback (undo
changes due to failure).
 Transactions ensure reliable and consistent database operations.
Example:
 Consider a bank transaction where ₹1000 is transferred from Account A
to Account B:
 Debit ₹1000 from Account A.
 Credit ₹1000 to Account B.
 If both operations are successful → Commit the transaction.
 If any operation fails → Rollback (restore previous state).
Introduction to ACID in DBMS
 ACID properties ensure reliable database transactions.
 • Atomicity
 • Consistency
 • Isolation
 • Durability
Atomicity
• Ensures transactions are all-
all-or-
or-nothing.
• If one part fails, the entire transaction fails.
fails.

Example: Bank Money Transfer


Suppose a user transfers ₹5000 from Account A to Account B. The transaction
involves two operations:
Deduct ₹5000 from Account A
Add ₹5000 to Account B
Case 1: Successful Transaction ✅
₹5000 is deducted from Account A.
₹5000 is added to Account B.
Transaction is committed, and changes are saved.
Case 2: Failure After Deduction (Atomicity in Action)❌
₹5000 is deducted from Account A.
❌ System crashes before adding ₹5000 to Account B.
Without Atomicity: Money is lost from Account A, and Account B never receives
it.
With Atomicity:The entire transaction is rolled back, restoring Account A’s balance
to its original state.
Consistency
 Ensures database remains in a valid state before and
after a transaction.
 Prevents invalid data from entering the database.
Example: Bank Transaction
A bank enforces a rule that an account balance cannot be negative.
Initial State:
Account A: ₹5000
Account B: ₹3000
Transaction: Transfer ₹6000 from A to B
Step 1: Deduct ₹6000 from Account A → Balance becomes ₹-1000 ❌
(Invalid)
Step 2: Add ₹6000 to Account B → Balance becomes ₹9000
Issue:
Account A's balance is now negative (-₹1000), violating the consistency
rule.
Isolation
 Ensures transactions do not interfere with each other.
 Prevents dirty reads, non-repeatable reads, and phantom
reads.
Example:Two users booking the last available ticket simultaneously.
Dirty Read:
 A Dirty Read occurs when a transaction reads data that has been
modified by another uncommitted transaction. If the modifying
transaction is later rolled back, the data read by the first transaction
becomes invalid or inconsistent, leading to potential data integrity
issues.
Example of Dirty Read:
 Transaction A updates a balance from ₹5000 to ₹6000 but has not
committed yet.
 Transaction B reads this updated balance as ₹6000.
 If Transaction A is rolled back, the balance should still be ₹5000,
but Transaction B already read incorrect data (₹6000).
Durability
• Ensures committed transactions remain in the database permanently.
• Even in case of system failure, data persists.
Example: Online Purchase
Imagine a user purchasing a mobile phone from an e-commerce website. The
transaction involves:
Deducting ₹50,000 from the user's bank account.
Updating the order status to 'Confirmed'.
 Case 1: Without Durability ❌
The transaction is completed.
Suddenly, the system crashes before saving the changes.
When the system restarts, the bank balance is still ₹50,000, and the order is
missing.
This leads to data inconsistency and loss.
 Case 2: With Durability ✅
The transaction is committed and stored permanently in the database.
Even if the system crashes, the order details and payment deduction remain
safe.
When the system restarts, the order is still "Confirmed" in the database.
Importance of ACID in Databases
 Ensures reliable and accurate transactions.
 Prevents data corruption and inconsistencies.
 Maintains system integrity in multi-user environments.
Conclusion

 ACID properties are fundamental for database


reliability.
 Ensures data integrity and consistency.
 Essential for financial, e-
e-commerce, and critical
applications.

You might also like