What are the ACID properties in a database?

Instruction: Explain the ACID (Atomicity, Consistency, Isolation, Durability) properties and their importance in database transactions.

Context: This question tests the candidate's understanding of the fundamental principles that ensure reliable transaction processing in database systems.

Updated

Official answer

ACID describes transaction properties:

  • Atomicity: the transaction's database changes commit together or are rolled back.
  • Consistency: correctly written transactions and enforced rules preserve the intended invariants; the database cannot infer every business rule.
  • Isolation: concurrent effects are constrained by the selected isolation level. Weaker levels do not behave as if all transactions ran one at a time.
  • Durability: acknowledged commits survive failures within the system's configured durability contract. This does not replace backups.

For a reservation, decrement available stock only if enough remains, check the affected-row result, and create the reservation in the same transaction. A preceding unlocked SELECT followed by an unconditional decrement can oversell under concurrency. A cross-row invariant may require stronger coordination than a single conditional update.

Sending a confirmation email is outside an ordinary database transaction. Commit an outbox record with the reservation and make delivery retry-safe; rolling back the database cannot unsend an email. Test concurrent requests, rollback and an unknown commit outcome. ACID is useful only when the operation's boundary and failure behavior are specified.

Related Questions