liveBook · Manning

Consistency

As explained in The Coder Cafe

Database consistency is the transaction property that requires a database to transition between valid states while preserving its integrity rules.

Consistency is the ACID property that requires a database transaction to move the database from one valid state to another. “Valid” means its integrity rules still hold after the transaction. Reliability therefore depends not just on completing operations, but on preserving the rules that make the stored data meaningful. section 6.1.1

Those rules can exist at two levels:

  • Transaction-level consistency: the database accepts only transactions that obey its predefined rules, such as foreign key constraints and data type requirements. section 6.1.1
  • Application-level consistency: a valid state may also depend on a business invariant, such as a required condition on customer balances. Database constraints alone do not necessarily define every such rule. section 6.1.1

A balanced financial transaction

Suppose a financial transaction must keep debits equal to credits. That balance is an invariant to check across the transaction. Atomicity answers a different question: if one step of a transfer fails, are all its steps rolled back? Both properties matter, but “all or nothing” does not itself state which resulting balances are valid. section 5.2.4 section 6.1.1

Do not confuse ACID consistency with consistency in CAP or PACELC. CAP uses the word for reads that receive the most recent write or an error; PACELC examines trade-offs involving that distributed-system guarantee during partitions and normal operation. ACID consistency instead asks whether transactions preserve valid states. Property-based testing can help check invariants across randomized inputs, including at the system level. section 6.1.1 section 6.2 section 6.3 section 5.2.4

How The Coder Cafe covers it

How deep it goes
Defines valid-state transitions and distinguishes database integrity rules from application invariants, without detailing an enforcement implementation.
Examples
Uses foreign key and data type requirements, customer balances, and balanced financial transactions as concrete rules.
What it assumes
Introduces ACID and its properties before explaining consistency; assumes no prior knowledge of distributed-system trade-offs.
What you can do after
Evaluate/understand whether transaction rules preserve valid states and avoid mistaking that property for distributed read freshness.
How it connects
Connects ACID transactions and integrity constraints to application invariants, while distinguishing CAP consistency and property-based testing.

Also explained in

Compare how 28 books explain consistency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.