State the grain
Name the entity represented by each row before joining tables.
Python and data workflows · EDITION 1.0.0
Build a SQLite diagnostic that contrasts raw ticket/tag/comment joins with a grain-preserving result and explains duplicate links and missing partners.
By Sanjaay Gowda T S · For sql analysts whose totals change unexpectedly after adding joins.
Runtime and hardware details
Python 3.10 or later and a terminal. The supplied project runs locally and uses the Python standard library.
No model, API key, cloud account or network calls are used by the companion.
SELECT, JOIN and GROUP BY; Primary and foreign key concepts; Basic Python to run the companion.
Full setup and scope ↓$2.99USD · one-time purchase
Prepared with AI assistance. Independent human technical, editorial and assistive-technology reader review remains pending. Automated checks and agent review are not certification.
PDF + EPUB + companion project. Any applicable tax is shown at checkout. Single-reader ebook terms; companion code is MIT licensed.

LOOK INSIDE
Actual pages from the 6-page free sample. Explore the introduction and Chapter 1 before choosing the complete edition.

Read the Pine Support setup and compare sixty effort minutes with 240 minutes after the raw join.
Open sample
Inspect the grain statements, candidate identities and deliberate duplicate relationship.
Open sample
Follow the worksheet on ownership, repeated values and the denominator behind an aggregate.
Open sampleAn excerpt from page 5 of the same public free sample. The complete sample remains available above.
Write one row represents one ticket beside the ticket table. Write one row represents one ticket-tag relationship beside tags, and one row represents one comment beside comments. These sentences describe different grains even though all tables contain ticket identities. A shared key does not make their rows interchangeable.
The ticket effort measure belongs to ticket grain. A tag has no share of that effort unless an allocation rule explicitly assigns one. A comment also has no automatic effort share. Copying ticket effort onto joined rows is a representation convenience, not evidence that each copy should participate in a sum.
| Relation | Intended grain | Candidate identity |
|---|---|---|
| ticket | One ticket | ticket_id |
| tag | One ticket-label link | ticket_id plus tag |
| comment | One comment | comment_id |
The fixture deliberately violates the intended tag-link uniqueness for T102. This allows the diagnostic to distinguish duplicate relationships from legitimate multiple tags. Ticket and comment identities are constrained before staging, while tag duplicates remain visible as a quality finding.
WHAT YOU WILL LEARN
Name the entity represented by each row before joining tables.
Calculate per-ticket join factors and compare them with actual SQL rows.
Aggregate enrichments separately and retain independent controls.
INSIDE THE BOOK
Python 3.10 or later and a terminal. The supplied project runs locally and uses the Python standard library.
No model, API key, cloud account or network calls are used by the companion.
Learning prerequisites: SELECT, JOIN and GROUP BY; Primary and foreign key concepts; Basic Python to run the companion.
Prepared with AI assistance. Independent human technical, editorial and assistive-technology reader review is pending.
The included examples are synthetic teaching material. Model access, software subscriptions, hosting, ongoing updates and consulting are not included.
CLEAR EXPECTATIONS
Build a SQLite diagnostic that contrasts raw ticket/tag/comment joins with a grain-preserving result and explains duplicate links and missing partners. The local companion uses fictional teaching fixtures. Project limits: Small in-memory current-state data; No team history or effort allocation policy; Raw unsafe query included only for diagnosis; No production performance or source repair claims.
The 13 companion tests passed on the packaged project. The supplied fictional fixture produced its recorded expected JSON output. EPUBCheck reported no errors or warnings; DAISY Ace and PDF/UA automated checks passed. These local teaching checks are not production accuracy claims or certification. Independent human technical, editorial and assistive-technology reader review remains pending.
Complete the secure Lemon Squeezy checkout to access the PDF, EPUB and companion ZIP. Keep your receipt and download access private. This is a one-time purchase of edition 1.0.0; ongoing updates and consulting are not included.
The full ebook is licensed to one reader. The labelled free sample may be shared unchanged. The companion project is MIT licensed and may be adapted or shared with its licence notice. See the exact ebook terms.
One book. A complete learning project. Evidence you can inspect.
AI-assisted · Independent human review pending