What is ACID?
Also known as: Atomicity, Consistency, Isolation, Durability
ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties guaranteeing reliable database transaction processing, ensuring data integrity despite concurrent access or failures.
ACID is an acronym for Atomicity, Consistency, Isolation, and Durability. These four properties are a set of guarantees that ensure database transactions are processed reliably. Atomicity means that a transaction is an all-or-nothing operation: either all of its changes are applied, or none are. Consistency ensures that a transaction transforms the database from one valid state to another, preserving all defined rules and constraints. Isolation makes concurrent transactions appear to execute serially, as if no other transactions are running, preventing data anomalies like dirty reads. Durability guarantees that once a transaction is committed, its changes survive system crashes or power losses, typically through write-ahead logging or persistent storage.
In practice, database systems enforce these properties through mechanisms like transaction logs, locking, and timestamps. For example, before any changes are written to the main data, they are first recorded in a transaction log. If a crash occurs before commit, the system can undo the partial changes (rollback). If the commit completes, the log ensures the changes can be reapplied after a restart. Isolation is typically implemented via pessimistic locking or optimistic concurrency control, with different isolation levels (such as Serializable, Repeatable Read, Read Committed) offering trade-offs between consistency and performance.
ACID is foundational to relational database management systems (RDBMS) like PostgreSQL, MySQL (with InnoDB), and Oracle. In distributed systems, achieving ACID properties across multiple nodes is more challenging and often requires expensive coordination protocols like two-phase commit (2PC). This has led to alternative models, such as BASE (Basically Available, Soft state, Eventual consistency), which relax consistency for better availability and scalability, as seen in many NoSQL databases.
Key facts
- Atomicity: a transaction is executed completely or not at all.
- Consistency: a transaction preserves database invariants and constraints.
- Isolation: concurrent transactions do not interfere with each other.
- Durability: committed changes persist even after system failure.
- The term ACID was coined in 1983 by Theo Härder and Andreas Reuter.
How it works in practice
Related terms
References
More in Databases
B-Tree Index
A B-Tree index is a self-balancing tree data structure that maintains sorted data for efficient insertion, deletion, and range queries in database systems.
BASE
BASE is a design philosophy for distributed databases that prioritizes availability and partition tolerance over immediate consistency, making it a looser alternative to ACID in NoSQL systems.
CAP Theorem
CAP theorem states that a distributed data system cannot simultaneously provide consistency, availability, and partition tolerance; it can only guarantee two of the three.
Connection Pool
A managed cache of database connections that applications reuse rather than opening and closing a connection for each query, reducing latency and server load.
Failover
Failover is the process of automatically or manually promoting a replica database to primary when the active node fails, ensuring continued availability.
Foreign Key
A column or set of columns in a database table whose values must match a primary key in another table, ensuring referential integrity between the two tables.
Hash Index
A data structure that maps keys to storage locations using a hash function, providing constant-time equality lookups but no ordered or range scans.
Materialized View
A database object that stores the precomputed result of a query as a table, refreshed periodically or on demand to improve read performance and reduce computational overhead.
NoSQL
NoSQL is a family of non-relational database systems designed for flexible schemas, horizontal scaling, and high-throughput data access that traditional SQL databases cannot easily provide.
Read Replica
A read replica is an asynchronously updated copy of a primary database instance used to offload and scale read-only query traffic without affecting the source database's write performance.