Chapter 35 — Exercises

Conceptual/reasoning exercises (this is a concepts chapter). (answer in Appendix) = worked solution in Answers. ⭐ = stretch.


Group A — Why distribute

A1 (35.1) Name four reasons to distribute a database and what each buys you. (answer in Appendix)

35.2 Why does a single well-tuned PostgreSQL server (plus replicas) suffice for most applications?


Group B — Replication

35.3 Explain primary-replica replication. What does the primary do vs. the replicas? (answer in Appendix)

35.4 Sync vs async replication — the trade-off? When would you require synchronous?

35.5 ⭐ How does replication provide both read scaling and high availability?


Group C — Sharding

35.6 What is sharding, and how does it differ from replication? Why is it "partitioning across machines"? (answer in Appendix)

35.7 Why are cross-shard queries and transactions expensive? How do you design to avoid them?

35.8 ⭐ Why is the shard key choice critical (hot spots, cross-shard queries)? (Tie to Chapter 25.)


Group D — CAP & consistency

35.9 State the CAP theorem. Why, since partitions are inevitable, is the real choice C vs A? (answer in Appendix)

35.10 For each, pick CP or AP and justify: a bank balance; a social media like-count; an inventory count; a news feed.

35.11 ⭐ What is eventual consistency, and for which of the above is it acceptable?


Group E — NewSQL & cloud

35.12 What problem does NewSQL (Spanner, CockroachDB) solve that traditional relational and NoSQL each don't? (answer in Appendix)

35.13 What do managed cloud databases (RDS, Aurora) handle for you, and why is "managed PostgreSQL + replicas" the right default for most teams?


Group F — Progressive project

35.14 Would your project be well served by one server + replicas? What's the first thing that would push you to distribute further?

35.15 Pick a CAP stance for your most critical data and justify it.

35.16 ⭐ If you had to shard, what shard key would you choose and what cross-shard queries would you avoid?


Self-check. If you can explain CAP, choose CP/AP per data, describe replication vs sharding, and resist premature distribution — you can reason about scale. Next: specialized databases.