Highlights

Contents

FUNDAMENTALS / CHAPTER 1 / FIELD GUIDEInside theDatabaseRelational theory, SQL and the storage engine.Follow a booking all the way to durable pages.keyrowsindexrowsFacts become pagesKeys choose an access path; the engine preserves the resultModel the factstables, keys, dependenciesExecute the queryplans, indexes, pagesCommit safelyversions, locks, write-ahead logOperate the systemreplicas, partitions, recovery
Before we start

How to read this chapter

Asha and Bharat both try to book the same theatre seat. This guide explains how a database chooses a valid outcome, preserves it after a crash, and answers queries about it.

Read in order to follow the complete mechanism, or use the contents for revision. After each drawing, explain what changes, what remains protected, and what could fail. The orange map locates the current part.

Each part ends with an “In one breath” recap. The interview page has short questions, graded reasoning exercises, and worked solutions. Explain the assumptions before consulting a formula.

The running example

Meet Heron in Pune

Heron is an illustrative Pune theatre-booking database. Asha, Bharat, and Charu are its query-fixture customers. The prices are ₹120, ₹120, and ₹80; amounts are integer rupees. This is a teaching service, not a real booking platform.

Setting Symbol or table Value What it controls
Customers users 100 rows Owners of bookings
Performances shows 8 rows Distinct seat inventories
Seats per performance SS 100 Capacity per show
Inventory show_seats 800 rows One row per show and seat
Existing bookings bookings 160 rows Query and join examples
Replicas nn 3 Quorum examples

The table defines the shared fixture. Toy storage sizes are not PostgreSQL’s physical layout; engine-specific behavior is identified separately. The companion calculation script is scripts/fundamentals/numbers.py.

The map

What is inside

Read in order for the complete mechanism, or use the contents to revise one topic. Each part highlights its place in the same map.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Database model2Keys and ER3Algebra and SQL4Dependencies5Storage and indexes6Query execution7Transactions8Concurrency control9Recovery and engines10Distributed databases11Application design12The complete query
  1. 01What the database promisesSections 1 to 3. Two theatre buyers can act on the same stale availability.
  2. 02Identity and relationshipsSections 4 to 6. A seat belongs to a performance, while a booking belongs to a customer.
  3. 03Relational algebra and SQLSections 7 to 13. A query needs precise row semantics.
  4. 04Dependencies and normalizationSections 14 to 22. Repeated facts can become contradictory updates.
  5. 05Storage and indexesSections 23 to 29. Finding a seat requires navigating physical storage.
  6. 06Query execution and optimizationSections 30 to 33. The same SQL can use several physical plans.
  7. 07Transactions and schedulesSections 34 to 38. A booking must remain correct across concurrent actions and crashes.
  8. 08Locks, versions and validationSections 39 to 43. Readers and writers can need different views of the same record.
  9. 09Recovery and storage enginesSections 44 to 48. A committed booking must survive its promised failures.
  10. 10Distributed databasesSections 49 to 52. Copies and shards add new state boundaries.
  11. 11Application design and PostgreSQLSections 53 to 56. Theatre bookings combine constraints, queries, and uncertain retries.
  12. 12The complete reservation querySections 57 to 60. Asha's receipt depends on more than finding a row.
  13. +Interview prepInterview question bank, graded exercises and worked solutions.