Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SQL Masterclass: Zero to Data Scientist

AI Bootcamp Open Graph preview

Welcome to the SQL Masterclass! This workshop is designed to take you from writing your first SELECT statement to authoring advanced data analytics pipelines with Window Functions, CTEs, and PostgreSQL-specific optimizations.

Regional pricing is available for eligible learners, with discounts of up to 60% in supported regions. Start here: https://www.learnwithparam.com/ai-bootcamp

📊 The Dataset (Olist E-Commerce)

This course uses a real-world e-commerce dataset containing over 100,000 orders from Olist, a Brazilian marketplace.

You will be querying real customers, real products, and real transactions across 9 tables.

┌──────────────────────┐ ┌──────────────────────┐
│ CUSTOMERS │ │ SELLERS │
│ customer_id (PK) │ │ seller_id (PK) │
│ zip_code, city, state│ │ zip_code, city, state│
└──────────┬───────────┘ └──────────┬───────────┘
│ │
│ 1 1 │
│ │
│ * * │
┌──────────▼───────────┐ ┌──────────▼───────────┐
│ ORDERS │ 1 * │ ORDER ITEMS │
│ order_id (PK) ├─────────► order_id (FK) │
│ customer_id (FK) │ │ product_id (FK) │
│ status, timestamps │ │ seller_id (FK) │
└──────────┬───────────┘ │ price, freight_value │
│ └──────────┬───────────┘
│ │ │ * * │ ┌──────────▼───────────┐ ┌──────────▼───────────┐
│ ORDER PAYMENTS │ │ PRODUCTS │
│ order_id (FK) │ │ product_id (PK) │
│ type, value, status │ │ category, weight, cm │
└──────────────────────┘ └──────────────────────┘

🚀 Getting Started: Self-Study Setup

This masterclass offers two ways to set up the practice database:

Option A: The Full Experience (PostgreSQL via Docker)

This is the recommended path. We use Docker to spin up a PostgreSQL 16 database specifically for this course, isolated on port 5439 so it never conflicts with your other local projects.

Prerequisites: Docker, Docker Compose, Python 3.

# 1. Enter the directorycd lwp-workshops/sql-masterclass
# 2. Prepare the environment (downloads data, sets up python dependencies)
make setup
# 3. Start the PostgreSQL database and Adminer UI (Background containers)
make up
# 4. Load the 100k+ rows of E-Commerce data into PostgreSQL
make init-db
# 5. Connect and start learning!# We provide Adminer, a lightweight web-based database explorer.# Go to: http://localhost:8080# System: PostgreSQL | Server: postgres | Username: postgres | Password: masterclass | Database: ecommerce# Or connect using any visual client (DBeaver, DataGrip) via:# Host: localhost | Port: 5439 | User: postgres | Pass: masterclass | DB: ecommerce# Or connect via CLI:
docker exec -it sql-masterclass-db psql -U postgres -d ecommerce

Option B: The Quick Start (SQLite)

If you don't have Docker, you can use SQLite. Note that Chapters 13–15 require PostgreSQL specifically and will not run on SQLite.

# 1. Enter the directorycd lwp-workshops/sql-masterclass
# 2. Make sure you ran `make setup` first to get the data
make setup
# 3. Initialize the SQLite database
make init-sqlite
# 4. Start practicing!
sqlite3 ecommerce.db

🧪 Testing Your Knowledge

We have included an automated test suite. As you complete exercises across the 15 chapters, simply run:

make verify

This will run every single Query your .sql files contain against your local database to proactively find syntax errors or table mismatches!


📚 The Curriculum

There are 15 .sql files in this directory. Each file contains explanations, heavily commented examples, exercises, and solutions. If you prefer reading Markdown, the docs/ folder contains a beautifully formatted Step-by-Step Lesson Guide with Mermaid diagrams for every single chapter.

LevelChapter FileTopics CoveredDoc Guide
🟢 Beginner01-select-basics.sqlSELECT, LIMIT, ASDoc
🟢 Beginner02-filtering-with-where.sql=, >, <, AND, OR, IN(), BETWEENDoc
🟢 Beginner03-sorting-and-distinct.sqlORDER BY, ASC, DESC, DISTINCTDoc
🟢 Beginner04-aggregate-functions.sqlSUM(), COUNT(), AVG(), MIN(), MAX()Doc
🟢 Beginner05-group-by-and-having.sqlGROUP BY, HAVINGDoc
🟡 Intermediate06-case-expressions.sqlCASE WHEN..., PivotDoc
🟡 Intermediate07-joins.sqlINNER, LEFT, CROSS, Self JoinsDoc
🟡 Intermediate08-subqueries-and-ctes.sqlSubqueries, WITH CTEsDoc
🟡 Intermediate09-set-operations.sqlUNION, INTERSECT, EXCEPTDoc
🔴 Advanced10-date-and-string-functions.sqlEXTRACT(), Date MathDoc
🔴 Advanced11-window-functions.sqlOVER(), ROW_NUMBER(), LAG()Doc
🔴 Advanced12-advanced-analytics.sqlCohorts, RFM, Funnels, CLVDoc
🟣 PostgreSQL13-postgresql-data-types.sql::NUMERIC, Arrays, JSONBDoc
🟣 PostgreSQL14-postgresql-functions.sqlDATE_TRUNC, FILTERDoc
🟣 PostgreSQL15-views-indexes-performance.sqlVIEW, INDEX, EXPLAINDoc
🟣 PostgreSQL16-schema-design-normalization.sql3NF vs Star Schema; Building Fact/Dimension tables.Doc
🟣 PostgreSQL17-advanced-indexing.sqlComposite, Partial (WHERE), and Expression indexes.Doc
🟣 PostgreSQL18-table-partitioning.sqlDeclarative Date Partitioning for massive scalability.Doc
🟣 PostgreSQL19-transactions-and-locks.sqlACID, BEGIN/COMMIT/ROLLBACK, and Row-Level Locks.Doc
🟣 PostgreSQL20-stored-procedures-triggers.sqlPL/pgSQL loops, custom functions, and Audit Triggers.Doc

About

Hands-on SQL masterclass material for building real AI and web apps.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages