Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


What are ACID properties in a database?

Educative Answers Team

A transaction is a collection of instructions. To maintain the integrity of a database, all transactions must obey ACID properties. ACID is an acronym for
atomicity, consistency, isolation, and durability. Let’s go over each of these properties.

1. Atomicity

A transaction is an atomic unit; hence, all the instructions within a transaction will successfully execute, or none of them will execute. The following transaction transfers 20 dollars from Alice’s bank account to Bob’s bank account. If any of the instructions fail, the entire transaction should abort and rollback.

svg viewer
A transaction to transfer 20 pounds from Alice's account to Bob's account.

2. Consistency

A database is initially in a consistent state, and it should remain consistent after every transaction. Suppose that the transaction in the previous example fails after Write(A_b) and the transaction is not rolled back; then, the database will be inconsistent as the sum of Alice and Bob’s money, after the transaction, will not be equal to the amount of money they had before the transaction.

3. Isolation

If the multiple transactions are running concurrently, they should not be affected by each other; i.e., the result should be the same as the result obtained if the transactions were running sequentially. Suppose B_bal is initially 100. If a context switch occurs after B_bal *= 20, then the changes should only be visible to T2 once T1 commits. This ensures consistency in the data and prevents incorrect results.

T1 adds 20% interest to Bob's savings account and T2 adds 20 pounds to Bob's account.

4. Durability

Changes that have been committed to the database should remain even in the case of software and system failure. For instance, if Bob’s account contains $120, this information should not disappear upon system or software failure.


Copyright ©2023 Educative, Inc. All rights reserved

View all Courses

Keep Exploring
Related Courses