SQL-Engineering-Handbook

Contributor Engineering Notes

Extended guidance for contributors extending Module 16. For basic conventions, see CONTRIBUTING.md.


Module Architecture

This module follows a three-layer documentation architecture:

Layer 1: Lessons (01–07)          — Conceptual teaching, one topic per file
Layer 2: Engineering Documents      — Reference, checklists, cookbooks, incidents
Layer 3: Labs & Practice            — Performance_lab/, PRACTICE_PROBLEMS.md

When adding content, place it in the correct layer. Don’t put reference material in lessons or teaching content in engineering docs.


Content Quality Standards

Every paragraph must teach something an experienced SQL engineer doesn’t already know, or explain something they know in a way that connects to production decision-making. Avoid:


Adding a New Lesson

  1. Choose the next number (08_, 09_, etc.)
  2. Create matching .md and .sql files
  3. Follow section order from CONTRIBUTING.md
  4. Add mermaid diagram for execution flow or architecture
  5. Include: Business Context, Real Company Usage, Interview Questions, Practice Challenges
  6. Update README Learning Flow table and Diagram Gallery
  7. Cross-link from relevant engineering documents

Adding to Engineering Documents

Document Add when…
PERFORMANCE_SMELLS.md New recurring code smell identified
REWRITE_COOKBOOK.md New canonical rewrite pattern validated with benchmark
PRODUCTION_INCIDENTS.md New realistic incident case study
CROSS_DATABASE_ENGINEERING.md New engine support or behavior change
ENGINEERING_GLOSSARY.md New term introduced in a lesson

SQL Lab Standards

Every .sql file must include:

-- BUSINESS OBJECTIVE: [one line]
-- PRODUCTION SCENARIO: [scale and context]
-- DATASET: [tables used]
-- PROBLEM STATEMENT: [business question]
-- PRODUCTION SQL: [the query]
-- ALTERNATIVE SQL: [rewrite or anti-pattern]
-- PERFORMANCE ANALYSIS: [what to look for in EXPLAIN]
-- INTERVIEW INSIGHT: [one Q&A]
-- FURTHER EXPERIMENTS: [2-3 suggestions]

Diagram Standards


Review Checklist for PRs