Designing Tables from the Questions They Need to Answer
A usable schema records enough identity, relationships, and measurement detail to answer representative queries accurately.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a catalogue question
“Which authors wrote each title” requires retaining author-to-book relationships. Storing one concatenated string can lose reliable lookup and rename behavior. Many-to-many relations preserve each pair.
Test with a counterexample
Use one book with several authors and an author associated with several books. Testable inputs distinguish designs that appear equivalent on a single one-to-one record.[1][2]
Start from a question that exposes the required grain
A report needs counts of active subscriptions by customer and month. A single current-state flag lacks past periods. A model storing start and end dates per subscription can support interval membership under a declared boundary rule. See data grain.
Required result: customer, month, active count
Source facts: stable customer, subscription ID, start, optional end
Decide whether a subscription active for part of a month counts
Test a query against the smallest realistic fixture
Include one subscription crossing a month boundary and another ending at it. Check current queries, consistency requirements and suitable indexes. Keep facts used for historical answers from being silently overwritten.