# ACID Databases – Atomicity, Consistency, Isolation & Durability Explained

![rw-book-cover](https://www.freecodecamp.org/news/content/images/2024/01/cover-fcc.png)

## Metadata
- Author: [[Daniel Adetunji]]
- Full Title: ACID Databases – Atomicity, Consistency, Isolation & Durability Explained
- Category: #articles
- URL: https://www.freecodecamp.org/news/acid-databases-explained/
- Archive: https://web-archive.alecodes.page/bookmarks?bf=1&search=&title=ACID%20Databases%20%E2%80%93%20Atomicity%2C%20Consistency%2C%20Isolation%20%26%20Durability%20Explained
> [!tldr]
> ACID (Atomicity, Consistency, Isolation, and Durability) is a set of guarantees provided by database management systems (DBMS). While most popular DBMS offer ACID guarantees, the implementation can vary. Atomicity ensures that all parts of a transaction are completed or none at all. Consistency, or referential integrity, ensures data accuracy and reliability. Isolation guarantees that concurrent transactions do not interfere with each other. Durability ensures that changes made by committed transactions are not lost. These properties are important for maintaining data integrity and fault tolerance in a DBMS.

## Highlights
Consistency in the context of ACID means *consistency in data*, which is defined by the creator of the database. The technical term for consistency in data is called referential integrity. __Referential integrity is a method of ensuring that relationships between tables remain consistent__. It's usually enforced through the use of **foreign keys**. [View Highlight](https://read.readwise.io/read/01j549yzv6a3s4x73cc7qj06rg))

Isolation is a guarantee that concurrently running transactions should not interfere with each other. Concurrency here refers to two or more transactions trying to modify or read the same database record(s) at the same time. [View Highlight](https://read.readwise.io/read/01j54a1g3dka9smm3v4ct09v4d))

In this example, read committed isolation ensures that Marie is not prematurely excluded from buying the burger just because someone else said they wanted it. __Only committed transactions can be read__. Therefore, the burger is available to be ordered as long as no one has paid for it. [View Highlight](https://read.readwise.io/read/01j54a6t2df5kjvy8q4tyhkwas))

A repeatable read guarantees that if a transaction reads a row of data, any subsequent reads of that same row of data within the same transaction will yield the same result, regardless of changes made by other transactions. This consistency is maintained throughout the duration of the transaction. [View Highlight](https://read.readwise.io/read/01j54a7baf7scbgptfwf5a5hgf))

Durability is a guarantee that changes made by a committed transaction must not be lost. All committed transactions must be persisted on durable, non-volatile storage, that is on disk. This ensures that any committed transactions are protected even if the database crashes. [View Highlight](https://read.readwise.io/read/01j54aa01whthekb1jegqsx42w))

