Data models and transactions
Model authoritative state, inspect queries, and protect concurrent changes.
Decide what a row means and who may change it
Several people can read the same bookmark while each has their own read/unread state. Two buyers can also race for the last item in stock. These examples show why a correct-looking table and a transaction keyword do not by themselves enforce the product’s rules.
Model identity and access patterns first. Then inspect query plans and drive conflicting writes in two PostgreSQL sessions. Keep the supplied PostgreSQL lab separate from the starter API’s SQLite database. Explain both returned rows and rejected operations.
Parts group related chapters. Each lesson has a chapter.lesson address, such as 4.07. Open a title below, or use Next to follow the reading sequence. Within a lesson, On this page lists its sections.
- 5.01
Model shared data and enforce changes with database constraints
Concepts and examples
- 5.02
Prevent overselling and write skew with the right transaction boundary
Concepts and examples
- 5.03
Drive conflicting transactions in two PostgreSQL sessions
Concepts and examples
- 5.04