Databases
Background and Invention
- What The Fuck is a Transaction?
A database transaction is a unit of work done within a DBMS against a database, and treated independently from other transactions. They serve two purposes:
- Provide reliable units of work that permit failure recovery and maintain database consistency even under system failure, if execution stops and leaves multiple operations uncompleted
- Provide isolation between programs accessing a database concurrently
Generally, any change or potential change in a database is a transaction.
- ACID
Transactions must follow the ACID paradigm:
- Atomicity: must be atomic, that is complete in its entirety or have no effect
- Consistency: must conform to existing constraints in the database
- Isolation: must not affect other transactions
- Durable: must be written to persistent storage
- CAP Theorem
Only two of the following three can be guaranteed for a distributed data store
- Consistency: Every read receives the most recent write, or an error
- Availability: Every request receives a (non-error) response, without the guarantee it contains the most recent write
- Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped by the network between nodes