This document explains how the SQL Engineering Handbook is organized, why it is structured this way, and how the different components interact. It is written for contributors, maintainers, and curious learners who want to understand the reasoning behind the repository design.
The SQL Engineering Handbook exists to bridge a gap in how SQL is taught. Most educational resources present SQL as a syntax-driven subject with disconnected examples. This project teaches SQL the way it is used inside real companies: starting with business problems, working toward solutions, and building a foundation for production analytics work.
This is not a cheat sheet. It is not a tutorial blog. It is an engineering handbook — built like the internal documentation of well-run data organizations.
| Aspect | Typical SQL Resource | SQL Engineering Handbook |
|---|---|---|
| Context | Bare code snippets | Business problem first, SQL second |
| Data | One generic toy table | Multiple real-world-style datasets (HR, e-commerce, sales, finance, healthcare) |
| Depth | Surface explanation | Why the approach works, common mistakes, performance notes, interview follow-ups |
| Standards | None enforced | Consistent formatting, naming, documentation across every module |
| Progress | Static | Live roadmap with versioned updates |
| Community | Solo or closed | Public contribution process with standards |
The handbook teaches reasoning before syntax. A learner should understand why a query is structured a certain way before memorizing that it should be structured that way. This means:
Code quality matters, even in educational contexts. Every SQL file is production-ready because:
Modules are not organized by SQL syntax. They are organized by business impact and progression of analytical power:
The repository must grow to 21 modules without becoming confusing or unnavigable. Achieved through:
01_, 02_, etc.) enforce sequential discoveryFuture maintainers (you, a team member, the community) must be able to understand the entire structure and add new modules without breaking existing ones. Achieved through:
.markdownlint.json and CI workflows enforce styleEvery module, every query, every documentation file must feel like it was written by the same team, even as contributors grow. Achieved through:
A visitor should be able to find what they need — whether sequential learning, targeted interview prep, or a specific SQL pattern. Achieved through:
Code and documentation should be written once and reused across multiple contexts. Achieved through:
datasets/ contains the truth; modules reference itIt should be easy to contribute. The barriers to entry should be low, but standards should be clear. Achieved through:
Every piece of code is a statement about intent and reasoning. Documentation is not an afterthought; it is the primary artifact. Achieved through:
Every query is written as if it would run in production tomorrow. Achieved through:
├── README.md Primary entry point; explains purpose and learning tracks
├── ROADMAP.md Live progress tracking; what's complete, what's next
├── CHANGELOG.md Version history; what changed and when
├── ARCHITECTURE.md This file; explains why the repo is organized this way
├── STYLE_GUIDE.md Standards every module and query follows
├── CONTRIBUTING.md How to contribute and review process
├── CODE_OF_CONDUCT.md Community standards and expectations
├── SECURITY.md How to report security concerns
├── FAQ.md Frequently asked questions
├── LICENSE MIT License
Each of these files serves a specific purpose in the maintenance and growth of the repository:
.github/
├── ISSUE_TEMPLATE/
│ ├── bug_report.md For reporting bugs
│ ├── feature_request.md For requesting new modules or features
│ └── documentation.md For documentation issues
├── PULL_REQUEST_TEMPLATE.md Guides contributor PRs
├── workflows/
│ ├── lint.yml Checks markdown and SQL formatting
│ └── ci.yml Runs automated validations
└── CODEOWNERS Specifies reviewers by file/directory
These files enforce consistency and guide the contribution process without maintainers needing to repeat themselves.
assets/
├── banners/ README banners and social images
├── diagrams/ Mermaid diagrams (roadmaps, relationships)
├── screenshots/ Step-by-step setup and usage images
├── logos/ Project branding
└── gifs/ Animated workflow examples
Visual assets support the documentation and make the repository more approachable.
datasets/
├── employee_management/ HR, hiring, departmental data
│ ├── schema.sql
│ ├── seed_data.sql
│ └── README.md
├── ecommerce/ Orders, customers, products
│ ├── schema.sql
│ ├── seed_data.sql
│ └── README.md
├── sales/ Deals, regions, quotas
├── finance/ Budgets, expenses, revenue
├── healthcare/ Patients, treatments, providers
└── nagpurlens/ City-based tourism and business data
Each dataset represents a real business context. Modules reference them, exercises practice on them, and projects build with them. This centralization ensures consistency and makes dataset updates automatic across all modules.
resources/
├── books.md Recommended reading on SQL and data
├── blogs.md Curated blog posts and articles
├── documentation.md Official database documentation links
├── youtube.md Video tutorials and talks
└── interview-resources.md Interview-specific prep material
These files curate external learning material without duplicating it. They answer “where do I learn more?” and “what do other experts recommend?”
cheatsheets/
├── joins/ All join types in one place
├── ctes/ CTE patterns and syntax
├── windows/ Window function reference
├── dates/ Date function syntax by database
├── strings/ String manipulation patterns
└── aggregation/ Aggregate function reference
Cheatsheets are frequency-based summaries of completed modules. They are generated after a module is complete, not before, ensuring they reflect actual module content.
exercises/
├── beginner/ 100-level challenges (Modules 01–03)
├── intermediate/ 200-level challenges (Modules 04–06)
├── advanced/ 300-level challenges (Modules 07–09)
└── interview/ Real interview questions and answers
Exercises are separate from modules but tied to them. A learner completes a module, then uses exercises to strengthen understanding. Difficulty levels match module progression.
projects/
├── hr-analytics/ Employee trends, turnover, compensation
├── ecommerce/ Customer lifetime value, cohort analysis
├── pizza-sales/ Restaurant analytics, peak hours, trends
├── olist/ Brazilian ecommerce multivendor analysis
└── nagpurlens/ Tourism and local business analytics
Projects are end-to-end case studies. They use completed modules and real-world datasets, forcing learners to apply concepts in context. Each project has:
00_SAMPLE_DATABASE/
01_FUNDAMENTALS/
02_AGGREGATIONS/
... (numbered up to 20)
Each module follows a standardized layout (see Module Architecture below). The numbering enforces sequence and prevents alphabetical confusion.
Numbering serves multiple purposes:
00 → 01 → 02 without jumping aroundThe progression is intentional and builds on itself:
Foundations (Modules 00–02)
Why this order? SELECT and WHERE are the foundation; aggregations build directly on them.
Core SQL (Modules 03–06)
Why this order? JOINs are the next capability after filtering. CASE WHEN is simpler than subqueries. Subqueries lead naturally to CTEs.
Analytical SQL (Modules 07–09)
Why this order? Window functions are the most complex core concept; business cases show their power before moving to supporting functions.
Engineering SQL (Modules 10–16)
Why this order? String functions and NULL handling unlock practical data work. Set operators extend aggregations. Views and indexes are organizational; optimization is the capstone.
Career Ready (Modules 17–20)
Why this order? Interview questions are narrowly scoped. Case studies and projects are broader. Cheatsheet is the final reference.
00 (Sample Database)
├→ 01 (Fundamentals)
│ ├→ 02 (Aggregations)
│ │ ├→ 03 (Joins)
│ │ │ ├→ 04 (CASE WHEN)
│ │ │ ├→ 05 (Subqueries)
│ │ │ │ └→ 06 (CTEs)
│ │ │ │ └→ 07 (Window Functions)
│ │ │ │ └→ 08 (Window Business Cases)
│ │ │ │ └→ 09 (Date Functions)
│ │ │ │ ├→ 10 (String Functions)
│ │ │ │ ├→ 11 (NULL Handling)
│ │ │ ├→ 12 (Advanced Aggregations)
│ │ │ ├→ 13 (Set Operators)
│ │ │ └→ 14-16 (Views, Indexes, Optimization)
│ └→ 17-20 (Interview, Case Studies, Projects, Cheatsheet)
A learner does not need to complete all of 01–09 before starting a project, but they should complete 01–03 before attempting 04. The ROADMAP shows estimated time and prerequisites.
Standardization solves multiple problems:
Every numbered module contains:
NN_MODULE_NAME/
├── README.md Learning objectives, overview, topics
├── 01_TOPIC_NAME.md First concept explanation and syntax
├── 01_TOPIC_NAME.sql First concept example queries
├── 02_TOPIC_NAME.md Second concept explanation
├── 02_TOPIC_NAME.sql Second concept examples
├── ... (additional topic pairs)
└── PRACTICE.md Practice problems and solutions
Every module README contains these sections in order:
This structure is consistent across all modules, making navigation predictable.
Each concept file (e.g., 01_SELECT.md) contains:
Each paired SQL file contains:
SQL files are executable as-is. Comments serve learners and maintainers equally.
Each module ends with a PRACTICE.md file containing:
The repository maintains these documentation files at the root level:
| File | Purpose | Audience |
|---|---|---|
| README.md | First impression; entry points and overview | Everyone |
| ROADMAP.md | Live progress; what’s done, what’s next | Contributors, learners checking status |
| ARCHITECTURE.md | This file; explains design decisions | Maintainers, advanced learners |
| STYLE_GUIDE.md | Format and tone standards | Contributors, reviewers |
| CONTRIBUTING.md | How to contribute and PR process | Potential contributors |
| CODE_OF_CONDUCT.md | Community standards and behavior | Everyone |
| SECURITY.md | How to report security issues | Everyone (especially security researchers) |
| FAQ.md | Common questions and answers | Learners with setup or usage issues |
| CHANGELOG.md | Version history and releases | Anyone tracking project maturity |
Each document is one source of truth. There is no duplication or contradiction between them.
Using toy datasets (a single employees table with 10 rows) teaches bad habits. Real data is:
By practicing on real-world-style datasets, learners:
| Industry | Dataset | Represents |
|---|---|---|
| HR & Staffing | employee_management | Hiring, departments, compensation |
| Retail & Ecommerce | ecommerce | Orders, customers, products, inventory |
| B2B Sales | sales | Deals, regions, quotas, territories |
| Finance | finance | Budgets, expenses, revenue, GL |
| Healthcare | healthcare | Patients, treatments, providers |
| Tourism & Local Business | nagpurlens | City businesses, tourism data |
Each dataset is documented in datasets/[name]/README.md with:
A single dataset (e.g., ecommerce) is used in:
This reuse means:
Every query, every markdown file, every code block must feel like part of one coherent resource.
SQL formatting is consistent:
a, b, t1)Markdown formatting is consistent:
Naming conventions are enforced:
NN_MODULE_NAME (zero-padded numbers)01_SELECT.md)employee_id, hire_date)NN_MODULE_NAME (e.g., 01_FUNDAMENTALS, 17_SQL_INTERVIEW_QUESTIONS)datasets, resources, cheatsheets)lint.yml, validate-sql.yml)NN_TOPIC_NAME.md and NN_TOPIC_NAME.sql (e.g., 01_SELECT.md, 01_SELECT.sql)schema.sql, seed_data.sql, README.mdreadme-banner.png, sql-roadmap.png)employees, orders, customers)employee_id, order_date, customer_name)e for employees, c for customers)active_users, monthly_totals)Every module must meet these standards:
visitor lands on GitHub
↓
README.md (first impressions)
↓
Decision point (goals?)
├→ Sequential learner → Start 00_SAMPLE_DATABASE
├→ Interview prep → 17_SQL_INTERVIEW_QUESTIONS (or exercises/interview)
├→ Desk reference → Use search/roadmap to find pattern
└→ Curious → ARCHITECTURE.md (this file)
↓
Pick entry point
↓
Module README (context and topics)
↓
Concept markdown files (learn)
↓
Concept SQL files (practice)
↓
PRACTICE.md (test understanding)
↓
Next module or project
Every path is intentional. The README lists these paths explicitly so visitors choose without confusion.
potential contributor
↓
README (see this is open source)
↓
CONTRIBUTING.md (understand process)
↓
Choose work (new module, fix, dataset, exercise)
↓
Fork & create branch
↓
Follow STYLE_GUIDE.md
↓
Open pull request with template
↓
Reviewer (maintainer) checks:
├→ STYLE_GUIDE compliance
├→ SQL runs without error
├→ Explanation is clear
├→ Links are valid
├→ No duplicate content
└→ Consistency with rest of repo
↓
Address feedback
↓
Approved → Merge
↓
Close related issues
↓
Update ROADMAP.md
↓
Bump version in CHANGELOG.md
This workflow prevents chaos as contributors grow.
graph LR
README["README.md<br/>(Entry point)"]
README -->|"What's here?"| ROADMAP["ROADMAP.md<br/>(Live status)"]
README -->|"How is it built?"| ARCHITECTURE["ARCHITECTURE.md<br/>(This file)"]
README -->|"How do I learn?"| MODULES["00-20 Modules<br/>(Numbered learning)"]
README -->|"How do I contribute?"| CONTRIBUTING["CONTRIBUTING.md<br/>(Guidelines)"]
MODULES -->|"Practice data"| DATASETS["datasets/<br/>(Real schemas)"]
MODULES -->|"Learn by doing"| EXERCISES["exercises/<br/>(Progressive challenges)"]
EXERCISES -->|"Full application"| PROJECTS["projects/<br/>(Portfolio work)"]
CONTRIBUTING -->|"Maintain consistency"| STYLE["STYLE_GUIDE.md<br/>(Standards)"]
CONTRIBUTING -->|"Report safely"| SECURITY["SECURITY.md<br/>(Disclosure)"]
CONTRIBUTING -->|"Be respectful"| CODE_OF_CONDUCT["CODE_OF_CONDUCT.md<br/>(Community)"]
ROADMAP -->|"Track changes"| CHANGELOG["CHANGELOG.md<br/>(Version history)"]
MODULES -->|"Quick reference"| CHEATSHEETS["cheatsheets/<br/>(Summaries)"]
MODULES -->|"Learn more"| RESOURCES["resources/<br/>(External links)"]
Every file serves a purpose in the ecosystem. New contributors should understand this dependency.
CONTRIBUTING.md — understand the processSTYLE_GUIDE.md — understand the standardsROADMAP.md to see what is already in progress (avoid duplicating work)NN_MODULE_NAME with correct numbering01_SELECT.md)git checkout -b fix/issue-nameReviewers check for:
Never ask a learner to memorize syntax. Teach them why the syntax exists and when to use it. A learner who understands the logical execution order of a SQL query can construct queries in contexts they have never seen before.
SQL is not just syntax. It is a tool for building systems. Every module touches on:
Every query is answering a business question. Before writing SQL, learners should be able to articulate:
This grounds SQL in reality, not in abstract syntax.
Production SQL is different from tutorial SQL. Tutorial code prioritizes brevity; production code prioritizes clarity and maintainability. Every example in this handbook is production-ready.
Consistency matters more than individual creativity. A repository that feels like one coherent resource is more valuable than a repository where every author has their own style. We enforce standards not to stifle, but to scale.
Write the documentation first. Write the SQL second. If you cannot explain a concept clearly, you do not understand it well enough. This inversion of typical priorities makes the entire repository stronger.
If STYLE_GUIDE.md or ARCHITECTURE.md needs to change:
The goal is stability with room for improvement.
The SQL Engineering Handbook is built to be:
This architecture enables all of these properties to coexist.
For questions about this document, open an issue or start a discussion.