Expected CTE facts are assertions only.
Honest by construction
Expected CTE facts are assertions only.
compiler is source of truth \text{compiler is source of truth} compiler is source of truth
Render checked rows
The guarded body query renders 3 rows after recomputation.
checked body rows = 3 \text{checked body rows}=3 checked body rows = 3
CTE examples are tiny finite-table transforms; recursive CTEs, materialization claims, optimizer behavior, SQL dialect completeness, and database-product claims are out of scope.
Honest by construction: base Students sid name status 1 Ada active 2 Bea paused 3 Cal active
Honest by construction: base Scores sid score 1 A 1 A2 3 C 4 D
Honest by construction: CTE ActiveStudents sid student 1 Ada 3 Cal
Honest by construction: body output left.sid left.score right.sid right.student 1 A 1 Ada 1 A2 1 Ada 3 C 3 Cal
CTE facts fact value baseTableCount 2 cteCount 1 cteNames [ActiveStudents] bodyRowCount 3 bodyColumnCount 4 referencedCtes [ActiveStudents] rowOrder source_order recursive no materializedClaim not_modeled
Try to tamper
Wrong expected facts, derived sidecars, duplicate names, missing references, recursive/materialized claims, bools, and floats fail closed.
tamper rejected \text{tamper rejected} tamper rejected
Summary
The book shows exact finite non-recursive CTE behavior only; product SQL behavior is outside the model.
scoped CTE model \text{scoped CTE model} scoped CTE model