Databases
Transactions: ACID and isolation
What a transaction promises, and which anomalies each isolation level allows.
In two minutes
One idea to a line
ACID: Atomicity (all or nothing), Consistency (rules hold before and after), Isolation (transactions do not see each other's unfinished work), Durability (committed data survives a crash).
Dirty read: reading uncommitted data. Non-repeatable read: a row read twice gives different values. Phantom: a repeated query returns extra rows.
READ UNCOMMITTED allows all three; READ COMMITTED stops dirty reads; REPEATABLE READ also stops non-repeatable reads; SERIALIZABLE stops phantoms too.
The log (write-ahead logging) is written before the data pages so the database can redo committed work and undo unfinished work after a crash.
A cascading rollback happens when aborting one transaction forces others that read its data to abort.
Slips people make here
Interviewers know them too
Mixing up non-repeatable read (same row, new value) and phantom (new rows).
Saying isolation levels are all the same across databases: the standard defines them by anomalies, products differ.
Thinking durability means no log is needed.
Your practice here
Not started
12 written questions
No answers yet