architect-handbook

Software Architect Handbook

View on GitHub

ACID (Relational DBs)

Overview

Set of properties of database transactions intended to guarantee data validity despite errors, power failures, and other mishaps.

Atomicity

A guarantee of atomicity prevents updates to the database occurring only partially, which can cause greater problems than rejecting the whole series outright. As a consequence, the transaction cannot be observed to be in progress by another database client. At one moment in time, it has not yet happened, and at the next it has already occurred in whole (or nothing happened if the transaction was cancelled in progress).

Consistency

Data

Reads

If a transaction committed a change, will a new transaction see the change immediately?

The moment you start using server replicas (horizontal scalability) you will suffer inconsistency, as secondary nodes will take time to get value propageted, so you might get an old value.

Isolation

Transactions are often executed concurrently (e.g., multiple transactions reading and writing to a table at the same time). Isolation ensures that concurrent execution of transactions leaves the database in the same state that would have been obtained if the transactions were executed sequentially.

Isolation is the main goal of concurrency control; depending on the method used, the effects of an incomplete transaction might not even be visible to other transactions.

Durability

Committed transactions must be persisted in a durable non-volatile storage.

For example, if you lose power, data should not be lost. E.g. Redis (cache) is not durable.