All guide activities

CH-05 · CHAPTER REVIEW

Databases indexes and transactions

Solve these two questions after studying the chapter. State your assumptions and explain your reasoning.

Read. Try. Defend.

Companion to the Buildfest System Design guides.

Chapter review: two questions

Attempt both questions before opening the model answers.

Question 1

For list-my-submissions, filter by learner and collection and order by created_at plus id. Propose an index and describe how to validate it.

Reveal model answer

A composite index on learner_id, collection, created_at and id is a useful hypothesis for this query shape. Check a representative query plan, row counts and latency distribution, and measure write overhead. The best exact index depends on the database, predicates, sort direction and workload.

Question 2

Two buyers race for one seat. Show the atomic decision, the losing response and the recovery if the winner's reply is lost after commit.

Reveal model answer

Use a conditional reservation update or correct locking transaction so one request wins. The loser receives an unavailable result. The winner retries using the same operation key and retrieves its stored result, rather than creating a second purchase. Record reservation and operation outcome consistently at the chosen boundary.

Answers stay in this tab. Download before leaving. This practice is not graded or saved to your account.