3 ms·
"Consistency - This one doesn't really belong on ACID as a property of databases, as it is a property of the application." Damn, that is not good on so many lev
by adontz 3y ago
"Consistency - This one doesn't really belong on ACID as a property of databases, as it is a property of the application."
Damn, that is not good on so many levels.
First of all, ACID are not properties of a database, they are properties of database transaction. Article kind of says it, but I feel it is phased ambiguous.
Consistency is the property of a database transaction which can be easily illustrated by foreign keys.
AUTHORS
| author_id | name |
| 1 | Mary |
| 2 | John |
ARTICLES
| article_id | author_id | title |
| 11 | 2 | About small animals |
| 12 | 1 | About big machines |
Now ARTICLES cannot have author_id non existent in AUTHORS. If a tuple is inserted in ARTICLES, then author_id should reference a valid tuple from AUTHORS.
If a tuple is deleted from AUTHORS, then all ARTICLES tuples referencing said AUTHORS tuple should be deleted too; or deleting from AUTHORS should be rejected.
That is consistency and that is a property of a database transaction. Transaction must fail if one tries to insert an article with author_id equal 5. At the end of transaction article 11 must be deleted if author 2 was deleted.
Now real life databases are much more complex, but idea is basically the same.
Also, consistency is between tuples. Not having "31-February-2001" as a date is integrity, not consistency.
- joshxyz 3y agodamn right sir, and there is also the term "consistency levels" which vary from one db to another.
- deleted 3y ago[deleted]
- tontinton 3y agoThanks, that's something I didn't know! I'll fix it later, and change the wording to say that these are properties of a database transaction
- senderista 3y agoI think the "C" in ACID indeed refers to application-defined integrity constraints (or "invariants"). Referential integrity is just one example; unique key constraints are another. This has nothing to do with the "C" in CAP, which is best interpreted (IMO) as linearizability. (Aside: IMO the "C" in ACID implies "I" and specifically serializability, because that is the only isolation level guaranteed to preserve arbitrary application invariants.)