ACID Properties Interview Questions

Master ACID Properties with interview-focused questions covering Atomicity, Consistency, Isolation, Durability, WAL, Redo Logs, Undo Logs, Crash Recovery, production scenarios, and enterprise best practices.

Introduction

ACID is the foundation of every reliable relational database.

Every transaction in enterprise databases follows the ACID principles to guarantee

  • Data Integrity
  • Data Consistency
  • Reliability
  • Fault Tolerance
  • Crash Recovery

Without ACID,

critical business applications such as

  • Banking
  • Stock Trading
  • Airline Booking
  • Healthcare
  • E-Commerce

would frequently lose or corrupt data.

ACID is one of the most frequently asked topics in Java, Database, and System Design interviews.


ACID Architecture

flowchart LR

Application --> Transaction

Transaction --> Atomicity

Transaction --> Consistency

Transaction --> Isolation

Transaction --> Durability --> Database

1. What is ACID?

Answer

ACID is a set of four properties that guarantee reliable database transactions.

ACID stands for

  • Atomicity
  • Consistency
  • Isolation
  • Durability

ACID Properties

ACID

├── Atomicity

├── Consistency

├── Isolation

└── Durability

2. Why is ACID important?

ACID ensures

  • No Partial Updates
  • Correct Business Data
  • Safe Concurrent Access
  • Recovery After Failure
  • Reliable Transactions

3. What is Atomicity?

Atomicity means

All operations execute successfully or none execute.

There is no partial transaction.


Atomicity Example

Money Transfer

Debit ₹1000

↓

Credit ₹1000

↓

Commit

If credit fails

Rollback debit


Atomicity Workflow

flowchart LR

BEGIN --> Operation1Operation2["Operation 1 --> Operation 2 --> Commit"]

Operation2["Operation 2"]

-.Failure.->

Rollback

4. How is Atomicity implemented?

Databases use

  • Undo Logs
  • Transaction Logs
  • Rollback Mechanisms

to restore previous values if a transaction fails.


5. What is Consistency?

Consistency ensures

the database moves

from one valid state

to another valid state.

Business rules

must always remain valid.


Consistency Example

Account Balance

Before

Account A

5000

Account B

7000

Total

12000

After transfer

4000

8000

Total remains

12000

6. How is Consistency maintained?

Using

  • Constraints
  • Primary Keys
  • Foreign Keys
  • CHECK Constraints
  • Triggers
  • Business Rules

7. What is Isolation?

Isolation ensures

concurrent transactions

do not interfere

with each other.

Every transaction behaves

as if it is executing alone.


Isolation Example

Transaction A

Updates Salary

↓

Transaction B

Cannot See

Uncommitted Data

Isolation Workflow

flowchart LR

TransactionA["Transaction A"] --> Database

TransactionB["Transaction B"] --> Database

Database --> IsolatedResults["Isolated Results"]

8. How is Isolation implemented?

Databases use

  • Locks
  • MVCC
  • Snapshot Isolation
  • Transaction Isolation Levels

9. What is Durability?

Durability ensures

once COMMIT succeeds,

the data

is permanently stored,

even if

  • Server Crashes
  • Power Failure
  • Database Restart

Durability Example

COMMIT

↓

Power Failure

↓

Restart

↓

Data Still Exists

Durability Workflow

flowchart LR

Commit --> TransactionLogDiskSuccess["Transaction Log --> Disk --> Success"]

10. How is Durability implemented?

Databases use

  • Write-Ahead Logging (WAL)
  • Redo Logs
  • Checkpoints
  • Disk Synchronization

11. What is Write-Ahead Logging (WAL)?

WAL writes

transaction changes

to the log

before

updating the actual data files.

Used by

  • PostgreSQL
  • SQLite

Similar mechanisms exist in other databases.


WAL Flow

Transaction

↓

WAL

↓

Disk

↓

Database File

12. What is a Redo Log?

Redo Logs

store committed changes

used for

crash recovery.

Commonly used in

  • Oracle
  • MySQL InnoDB

13. What is an Undo Log?

Undo Logs

store previous values

allowing

ROLLBACK

and

consistent reads.


Undo Workflow

Old Value

↓

Undo Log

↓

Rollback

↓

Restore

14. What happens during COMMIT?

Typical workflow

Execute SQL

↓

Write Transaction Log

↓

Flush Log to Disk

↓

Commit

↓

Success

15. What happens during ROLLBACK?

Database reads

Undo Log

and restores

the previous values.


Rollback Workflow

flowchart LR

Failure --> UndoLogRestoredatarestoreData["Undo Log --> RestoreData["Restore Data"]"]

16. Can Atomicity exist without Durability?

No.

A transaction system must satisfy all ACID properties together.

Each property complements the others.


17. Can Consistency be violated?

Yes.

If

  • Constraints are disabled
  • Bugs exist in application logic
  • Incorrect business rules are implemented

the database may become logically inconsistent.


18. Does ACID reduce performance?

Sometimes.

Because databases perform

  • Logging
  • Locking
  • Synchronization
  • Recovery Operations

However,

these overheads provide reliability.


19. Banking Example

Transfer Money

Debit

↓

Credit

↓

Commit

↓

Permanent

20. Stock Trading Example

Buy Shares

Update Portfolio

Update Wallet

Commit


21. Airline Booking Example

Reserve Seat

Payment

Ticket

Commit

No duplicate seat allocation.


22. Healthcare Example

Patient Registration

Medical Record

Billing

Commit


23. E-Commerce Example

Create Order

Reduce Inventory

Payment

Commit


24. Insurance Example

Claim Approval

Update Policy

Create Payment

Commit


25. Production Example

Salary Processing

Update Payroll

Update Tax

Update PF

Commit

Entire payroll succeeds or rolls back.


26. Advantages of ACID

  • Reliable Transactions
  • Data Integrity
  • Crash Recovery
  • Consistency
  • Safe Concurrency
  • Business Reliability

27. Limitations of ACID

  • Additional Logging
  • Locking Overhead
  • Slightly Lower Throughput
  • More Disk Writes
  • Increased Complexity

28. Common Mistakes

  • Long Transactions
  • Ignoring Rollback
  • Mixing Multiple Business Processes
  • Improper Error Handling
  • Assuming COMMIT is Instant

29. Performance Tips

  • Keep transactions short.
  • Commit quickly.
  • Use proper indexes.
  • Avoid unnecessary locks.
  • Choose suitable isolation levels.
  • Monitor transaction logs.
  • Tune checkpoint frequency (database dependent).

30. What are the best practices?

  • Design one transaction per business operation.
  • Handle every failure with rollback.
  • Keep transactions short.
  • Monitor transaction log growth.
  • Use constraints to maintain consistency.
  • Use appropriate isolation levels.
  • Regularly test crash recovery.
  • Monitor WAL/Redo Log performance.
  • Validate business rules before commit.
  • Continuously monitor database health.

ACID Workflow

flowchart LR

BEGIN --> Atomicity --> Consistency --> Isolation --> Durability --> COMMIT

Enterprise Best Practices

  • Design every business operation around ACID principles.
  • Keep transactions as short as possible.
  • Monitor WAL, Redo Log, and Undo Log usage.
  • Configure checkpoints appropriately.
  • Use constraints to protect consistency.
  • Select isolation levels based on business needs.
  • Test crash recovery procedures regularly.
  • Monitor lock contention.
  • Benchmark transaction throughput.
  • Continuously audit business-critical transactions.

Quick Revision

Property Meaning
Atomicity All or Nothing
Consistency Valid State to Valid State
Isolation Transactions Don't Interfere
Durability Committed Data Never Lost
WAL Log Before Data
Redo Log Recover Committed Data
Undo Log Rollback Changes
Commit Save Permanently
Rollback Undo Changes
Constraints Maintain Consistency

Interview Tips

Interviewers frequently ask

  • What is ACID?
  • Explain Atomicity.
  • Explain Consistency.
  • Explain Isolation.
  • Explain Durability.
  • WAL vs Redo Log vs Undo Log.
  • How does COMMIT work internally?
  • How does ROLLBACK work?
  • Why is ACID important?
  • Give a real-world example.

A strong interview explanation is:

"ACID is a set of four properties that ensure reliable database transactions. Atomicity guarantees that all operations succeed or none do. Consistency ensures every transaction moves the database from one valid state to another while enforcing business rules. Isolation prevents concurrent transactions from interfering with one another through mechanisms such as locks or MVCC. Durability guarantees that once a transaction commits, its changes are permanently stored using mechanisms such as Write-Ahead Logging (WAL), Redo Logs, and crash recovery."


Summary

ACID properties form the foundation of reliable relational database systems. They ensure transactions execute safely, maintain business consistency, recover from failures, and protect committed data. Understanding Atomicity, Consistency, Isolation, Durability, WAL, Redo Logs, Undo Logs, Commit, Rollback, and crash recovery is essential for Backend Developers, Database Engineers, Java Developers, and Solution Architects.

Mastering ACID provides the foundation for advanced topics such as Isolation Levels, Locking, Deadlocks, MVCC, Distributed Transactions, and Database Performance Tuning.