Database
Table of contents
ACID / BASE
ACID
- Atomicity: All operations in a transaction are atomic, meaning they either all succeed or none happen (single failure rolls back the entire transaction).
- Consistency: A transaction does not break any invariants set by DB. A DB must be in a valid state before and after a transaction.
- Isolation: The end result of a DB after concurrent transactions and sequential transactions must be the same. All transactions must operate as if they were operating on an isolated DB.
- Durability: Once a transaction is committed, the commit is retained even after a system failure.
ACID transaction has been the norm for relational databases. It is more conservative in a sense and more suitable in domains where data safety is critical (financial institutes). However, it is generally considered to be slower due to heavy locking.
BASE
- Basic Availiability: Reading and writing is available whenever possible.
- Soft-state: State of the system do not ensure write consistency, and replica nodes are not guranteed to be consistent with each other.
- Eventually consistent: Given time, system will eventually converge to a known state.
Where throughput is deemed higher importance than immediate consistency, ACID may be too restrictive. BASE transaction is more optimistic in locking compared to ACID. Many NoSQL databases adhere to BASE when data safety is less of a risk.
CAP Theory
TBA
ORM
TBA
References: