Database ACID properties — what they mean and why they matter
Table of Contents
ACID is one of the landmark concepts that has helped database systems succeed and become so useful. It was actually introduced nearly half a century ago by Theo Haerder and Andreas Reuter1.
Transactions #
To understand the ACID properties, it’s important to understand what a transaction is first.
Fundamentally, databases contain data that a system will read and write from. The data may be frequently accessed and by many consumers. These accesses need to be safe and provide a reliable view of the data, especially for critical use cases like finance or medicine.
A transaction groups together a series of operations so that they appear as a single unit of work to the outside world. Only if all the operations succeed, the transaction is then “committed”, which finalizes and writes the data. Otherwise, the transaction is “rolled back”, undoing any operation steps that were performed.
In this way, a transaction serves as an incredibly useful abstraction. However, the database needs to guarantee a few things to be able to support transactions.
ACID properties #
The ACID properties make transactions possible by keeping the database in a consistent state.
Atomicity #
Either all operations in a group succeed or none succeed.
For example, if one step fails, the entire transaction fails. The database state is rolled back to what it was before the transaction.
Consistency #
When a transaction successfully commits, that becomes the updated database state. When multiple transactions happen after each other, the database will apply each transaction to the state the previous transaction left it in.
Isolation #
When multiple transactions happen concurrently, the database will apply each transaction after the other. This does not necessarily guarantee a specific order of the transactions, but it does ensure all of the steps happen in order within each transaction.
Suppose there are two transactions, TX and TY.
- TX transfers $10 from A to B
- TY transfers $60 from B to C
TX happens before TY #
TY happens before TX #
Durability #
This essentially means that a committed transaction is written in stone. After a transaction is committed, later failures in the database will never undo the change that this transaction made.
(Though, another successful transaction can reverse the change made by this original transaction.)
Supported database systems #
The popular relational database systems are all ACID compliant: Postgres, MySQL, SQL Server, and Oracle.
Some non-relational databases, such as MongoDB (document database) and Neo4j (graph database), are also ACID compliant.
Not all database systems support ACID (or even transactions) though, like for example, Apache Cassandra (a NoSQL database).
-
Theo Haerder and Andreas Reuter. 1983. Principles of transaction-oriented database recovery. ACM Comput. Surv. 15, 4 (December 1983), 287–317. https://doi.org/10.1145/289.291 ↩︎