Part 5 of 5 · 4 min read
Exercises
Easy
Easy 1: Name the four ACID properties (15 minutes)
Name the four ACID properties in order.
Done when: atomicity, consistency, isolation, and durability are all correctly named in order.
Hint
Atomicity, consistency, isolation, durability.
Easy 2: Match atomicity to a scenario (15 minutes)
State which ACID property is violated if a crash leaves a debit applied but its matching credit missing.
Done when: atomicity is correctly named.
Hint
Atomicity.
Easy 3: Match durability to a scenario (15 minutes)
State which ACID property is violated if a committed transaction's changes disappear after a crash.
Done when: durability is correctly named.
Hint
Durability.
Medium
Medium 1: Explain why consistency depends on declared rules (25 minutes)
Explain why consistency is described as depending on what the application and schema designer declare, unlike the other three properties.
Done when: the explanation correctly notes that without a declared constraint, such as a CHECK on balance, the database has no rule to enforce, so logically wrong data could still be committed even with perfect atomicity, isolation, and durability.
Hint
Without a declared rule such as a CHECK constraint, there is nothing for the database to enforce, so even perfect atomicity, isolation, and durability would not stop logically wrong data from being committed.
Medium 2: Distinguish isolation from atomicity (25 minutes)
Explain the difference between what isolation guarantees and what atomicity guarantees, using the bank transfer example.
Done when: the explanation correctly states atomicity concerns whether the transfer completes entirely or not at all, while isolation concerns whether another concurrent transaction can see the transfer's intermediate, half-finished state.
Hint
Atomicity is about whether the transfer's steps all complete together or not at all; isolation is about whether another transaction can see the transfer's state while it is still only partly done.
Medium 3: Distinguish isolation from durability (30 minutes)
Explain why isolation and durability address different moments in a transaction's lifecycle.
Done when: the explanation correctly notes isolation concerns the period while a transaction is still running concurrently with others, while durability concerns the period after a transaction has already committed.
Hint
Isolation concerns the window while a transaction is still actively running alongside others; durability concerns what happens afterward, once that transaction has already committed.
Hard
Hard 1: Diagnose a missing-constraint scenario (30 minutes)
A database correctly provides atomicity, isolation, and durability, but a bug allows a quantity column to go negative because no CHECK constraint was ever added. Explain which ACID property this failure falls under, and why the other three being correct does not prevent it.
Done when: the explanation correctly identifies this as a consistency failure, noting that consistency depends on declared rules existing in the first place, which the other three properties do not provide on their own.
Hint
This is a consistency failure, since consistency depends on rules actually being declared; the other three properties guarantee completion, concurrency safety, and crash survival, but none of them invent a missing business rule on their own.
Hard 2: Explain why atomicity alone does not guarantee isolation (35 minutes)
Explain why a database providing perfect atomicity, guaranteeing a transaction's effects all happen together or not at all, does not automatically guarantee isolation as well.
Done when: the explanation correctly notes that atomicity only concerns whether one transaction's own changes are all-or-nothing, while isolation separately concerns whether other concurrent transactions can observe those changes before they are finalized, a different question entirely.
Hint
Atomicity only addresses whether one transaction's own effects are all-or-nothing; it says nothing about whether another transaction running at the same time can observe those effects before they are finalized, which is isolation's separate concern.
Hard 3: Trace a crash scenario through all four properties (40 minutes)
A bank transfer transaction crashes midway through, after its debit but before its credit, while a second transaction is concurrently reading account balances. Walk through what each of the four ACID properties specifically guarantees will or will not happen in this scenario.
Done when: the walkthrough correctly states atomicity guarantees the partial debit will be undone, isolation guarantees the concurrent reader does not see the inconsistent, half-applied state in the meantime, durability guarantees that if the transfer had already committed before the crash its changes would survive, and consistency guarantees that whatever final state is reached still satisfies the schema's declared rules.
Hint
Atomicity undoes the partial debit; isolation keeps the concurrent reader from seeing the half-applied state while the transfer is in progress; durability would have protected the transfer's changes had it already committed before the crash; consistency ensures whatever final state results still satisfies the schema's declared rules.