Transactions are needed because they provide a way to handle various system failures, errors, and concurrent operations by grouping multiple database operations into a single atomic unit that either completely succeeds or fails, simplifying error handling and maintaining data consistency.
The Meaning of ACID
A - Atomicity : Either all operations complete successfully or none of them take effect, with automatic rollback if any part fails.
C - Consistency: foreign key constraints or uniqueness constraints.
I - Isolation: Serializable. Concurrent transactions operate independently and cannot interfere with each other, ensuring data consistency as if the transactions were executed one after another sequentially, though they may actually run simultaneously
D - Durability: data can be stored without fear of losing it.
Weak Isolation Levels
- No Dirty Reads
- No Dirty Writes
- Snapshot Isolation and Repeatable Read
- No Lost updates
- No Write Skews
- No Phantoms Reads
- Serializability a. Actual Serial Execution b. Two Phase Locking (2PL) c. Serializable Sanpshot Isolation (SSI)