Database
Mastering SQL
A complete, 17-module SQL course - from databases, querying, joins and aggregations through window functions, indexing, transactions, SQL at scale, and 14 FAANG interview patterns. Built by a Netflix data leader.
Mastering SQL: Fundamentals to FAANG Interviews
This is the SQL course built the way SQL is actually used in production - and the way it is actually tested in interviews. Authored by Emeka Okafor (Head of Data Infrastructure at Netflix), it runs from the absolute basics all the way to the patterns that separate a "knows SQL" candidate from a "thinks in SQL" one.
You'll start with the foundations (what a database really is, the relational model, keys, normalization), move through everyday querying (SELECT, filtering, NULL handling, CASE, dates), aggregations and every flavour of JOIN, then into the depth most courses skip: subqueries and CTEs, the full window-function toolkit, set operations, DDL/DML, data modeling, indexing and execution plans, transactions and concurrency (ACID, isolation levels, locking, MVCC), and SQL at scale (OLTP vs OLAP, columnar stores, partitioning, streaming SQL).
It closes with two interview-grade modules: 14 named interview patterns (top-N per group, gaps and islands, running totals, sessionization, pivots, and more) and a strategy + mock module on how FAANG SQL rounds actually run.
The first two modules - Welcome and SQL Foundations - are free to preview. The full course is a one-time purchase with lifetime access.
What you will learn
- The relational model from first principles — tables, keys, constraints, normalization and when to denormalize
- Querying fluently: filtering, NULL logic, CASE, DISTINCT, pattern matching, dates and type casting
- Aggregations and every JOIN type, including self-joins and join performance
- Subqueries, correlated subqueries, EXISTS, and (recursive) Common Table Expressions
- The complete window-function toolkit — ranking, LAG/LEAD, frames, and PARTITION BY in depth
- Indexing, EXPLAIN and execution plans, and how the query planner thinks
- Transactions and concurrency: ACID, isolation levels, locking, deadlocks and MVCC
- SQL at scale — OLTP vs OLAP, columnar warehouses, partitioning, sharding and streaming SQL
- 14 FAANG SQL interview patterns plus a strategy + mock module on how the rounds actually run
Prerequisites
- No prior SQL needed — we start from "what is a database?"
Course outline
Module 1: Welcome & Orientation
Welcome & Orientation — 4 topics.
- Your SQL Roadmap - From First Query to FAANG Interview 10 min read
- How This Course Works - Format, Exercises, and How to Get the Most Out of Every Lesson 11 min read
- Meet Emeka - Lagos to Netflix 11 min read
- A Note on SQL Dialects - Why Your Query Works Here but Breaks There 10 min read
Module 2: SQL Foundations
SQL Foundations — 6 topics.
- What Is SQL? 10 min read
- The Relational Model - How Data Lives in Tables 11 min read Pro lesson
- Keys and Constraints - Enforcing Identity and Data Integrity 10 min read Pro lesson
- Normalization - Cleaning Up Messy Tables 10 min read Pro lesson
- Denormalization - When Breaking the Rules Makes Sense 10 min read Pro lesson
- Three-Valued Logic and NULL Semantics - The Most Common SQL Interview Trap 10 min read
Module 3: Querying Data
Querying Data — 11 topics.
- The SELECT Statement - Your First Real Query 14 min read Pro lesson
- Filtering with WHERE - Choosing Which Rows to Return 11 min read Pro lesson
- BETWEEN and IN - Range and Set Filtering 11 min read Pro lesson
- LIKE and Pattern Matching - Searching Within Text 10 min read Pro lesson
- NULL Handling and COALESCE - Practical Patterns for Working with NULLs 11 min read Pro lesson
- CASE WHEN Expressions - Conditional Logic Inside Queries 10 min read Pro lesson
- Sorting and Pagination - Controlling Order and Row Count 10 min read Pro lesson
- DISTINCT - Removing Duplicate Rows and Knowing When Not To 10 min read Pro lesson
- Scalar Functions - Strings, Numbers, and Dates 10 min read Pro lesson
- Date and Time - The Full Reference and the Timezone Trap 10 min read Pro lesson
- Table and Column Aliases - Naming Things Clearly 10 min read Pro lesson
Module 4: Aggregations
Aggregations — 5 topics.
- Aggregate Functions - COUNT, SUM, AVG 10 min read Pro lesson
- MIN, MAX, and Finding Rows with Extreme Values 10 min read Pro lesson
- GROUP BY and HAVING - Aggregating by Category 10 min read Pro lesson
- Advanced Grouping - ROLLUP, CUBE, and GROUPING SETS 10 min read Pro lesson
- String and Conditional Aggregation - The Analytics Power Patterns 10 min read Pro lesson
Module 5: Joins
Joins — 8 topics.
- Introduction to Joins - Combining Data from Multiple Tables 10 min read Pro lesson
- INNER JOIN - Only Matching Rows Survive 10 min read Pro lesson
- LEFT JOIN - All Left Rows Survive 10 min read Pro lesson
- RIGHT JOIN - The Mirror of LEFT JOIN 10 min read Pro lesson
- FULL OUTER JOIN - Both Sides Survive 10 min read Pro lesson
- CROSS JOIN - The Cartesian Product 10 min read Pro lesson
- SELF JOIN - Joining a Table to Itself 10 min read Pro lesson
- LATERAL JOIN and Join Interview Patterns 10 min read Pro lesson
Module 6: Subqueries & CTEs
Subqueries & CTEs — 5 topics.
- Subquery Fundamentals - Queries Inside Queries 10 min read Pro lesson
- EXISTS, NOT EXISTS, IN, and NOT IN - Semi-Joins and Anti-Joins 10 min read Pro lesson
- Correlated Subqueries - Subqueries That Reference the Outer Query 10 min read Pro lesson
- Common Table Expressions (CTEs) - Writing Queries as Paragraphs of Thought 10 min read Pro lesson
- Recursive CTEs - Traversing Hierarchies and Generating Sequences 10 min read Pro lesson
Module 7: Window Functions
Window Functions — 9 topics.
- Introduction to Window Functions - Aggregate Without Collapsing 10 min read Pro lesson
- ROW_NUMBER - Sequential Numbering and the Top-N-Per-Group Pattern 10 min read Pro lesson
- RANK, DENSE_RANK, and Distribution Functions - Handling Ties 10 min read Pro lesson
- LAG, LEAD, and Row Comparison - Accessing Previous and Next Rows 10 min read Pro lesson
- FIRST_VALUE, LAST_VALUE, NTH_VALUE - Accessing Specific Rows in a Window 10 min read Pro lesson
- Window Aggregates - Running Totals and Moving Averages 10 min read Pro lesson
- Frame Clauses Done Right - ROWS vs RANGE vs GROUPS 11 min read Pro lesson
- Gaps and Islands - The Classic Interview Pattern 10 min read Pro lesson
- Window Functions Interview Cheat Sheet - The Five Patterns That Cover 90% 10 min read Pro lesson
Module 8: Set Operations & Reshaping
Set Operations & Reshaping — 3 topics.
- UNION and UNION ALL - Stacking Result Sets 10 min read Pro lesson
- INTERSECT and EXCEPT - Set Intersection and Set Difference 11 min read Pro lesson
- Pivoting and Unpivoting Data - Reshaping Rows and Columns 10 min read Pro lesson
Module 9: Data Definition & Manipulation
Data Definition & Manipulation — 5 topics.
- CREATE TABLE and ALTER TABLE - Building and Modifying Data Structures 10 min read Pro lesson
- INSERT, UPDATE, DELETE, and UPSERT - Modifying Data 10 min read Pro lesson
- Views and Materialized Views - Reusable Query Definitions 10 min read Pro lesson
- Temporary Tables and Table Variables - Session-Scoped Working Storage 11 min read Pro lesson
- JSON in SQL - When Relational Meets Semi-Structured Data 10 min read Pro lesson
Module 10: Data Modeling
Data Modeling — 4 topics.
- Entity-Relationship Modeling - From Business Problem to Schema 11 min read Pro lesson
- Normal Forms in Practice - When Structure Prevents Chaos 10 min read Pro lesson
- Denormalization Strategies - Breaking the Rules for Performance 10 min read Pro lesson
- Star Schema and Snowflake Schema - Dimensional Modeling for Analytics 10 min read Pro lesson
Module 11: Indexing & Performance
Indexing & Performance — 5 topics.
- How Indexes Work - The Data Structure Behind Fast Queries 10 min read Pro lesson
- Composite, Partial, and Covering Indexes - Precision Index Design 10 min read Pro lesson
- EXPLAIN and Reading Execution Plans - Seeing What the Database Does 10 min read Pro lesson
- How the Query Planner Thinks - Statistics, Selectivity, and Cardinality 10 min read Pro lesson
- Query Optimization and Anti-Patterns - The Top Ten SQL Mistakes 11 min read Pro lesson
Module 12: Transactions & Concurrency
Transactions & Concurrency — 6 topics.
- What Is a Transaction? - The Indivisible Unit of Work 10 min read Pro lesson
- ACID Properties - The Four Guarantees of Reliable Transactions 10 min read Pro lesson
- Isolation Levels - Controlling What Concurrent Transactions Can See 10 min read Pro lesson
- Locking Mechanisms - Row Locks, Table Locks, and Explicit Locking 10 min read Pro lesson
- Deadlocks - When Transactions Wait Forever 10 min read Pro lesson
- MVCC - Multi-Version Concurrency Control 10 min read Pro lesson
Module 13: SQL at Scale
SQL at Scale — 5 topics.
- OLTP vs OLAP - Two Worlds of SQL 10 min read Pro lesson
- Columnar Stores and the Data Warehouse - How Analytics Gets Fast 10 min read Pro lesson
- Partitioning and Sharding - Distributing Data for Scale 10 min read Pro lesson
- Streaming SQL - Flink, KSQL, and the Netflix Lens 10 min read Pro lesson
- SQL in the Modern Data Stack - dbt, ELT, and the Future 10 min read Pro lesson
Module 14: Procedural SQL
Procedural SQL — 3 topics.
- User-Defined Functions (UDFs) - Extending SQL's Vocabulary 10 min read Pro lesson
- Stored Procedures and Procedural SQL - Logic Inside the Database 10 min read Pro lesson
- Triggers - Automatic Logic on Data Changes 11 min read Pro lesson
Module 15: Database Security
Database Security — 3 topics.
- Users, Roles, and Privileges - Controlling Who Can Do What 11 min read Pro lesson
- Row-Level and Column-Level Security - Granular Data Protection 11 min read Pro lesson
- SQL Injection and Safe Query Construction - The Most Dangerous Vulnerability 11 min read Pro lesson
Module 16: Interview Patterns
Interview Patterns — 14 topics.
- SQL Gotchas and Tricky Behavior - Ten Things That Trip Up Candidates 11 min read Pro lesson
- Top-N per Group - The Most Common FAANG SQL Pattern 10 min read Pro lesson
- Nth Highest / Nth Value - The Classic Interview Question 10 min read Pro lesson
- Finding and Removing Duplicates - Identification, Deduplication, and Prevention 11 min read Pro lesson
- Consecutive Records and Streaks - Gaps and Islands 10 min read Pro lesson
- Period-over-Period Comparisons - MoM, YoY, and Growth Analysis 10 min read Pro lesson
- Running Totals and Cumulative Calculations - The Expanding Window 10 min read Pro lesson
- Gaps in Sequences - Finding What Is Missing 10 min read Pro lesson
- Funnel Analysis, Cohorts, and Retention - Measuring User Journeys 10 min read Pro lesson
- Sessionization and Time-Based Grouping - Building Sessions from Raw Events 10 min read Pro lesson
- Hierarchical Queries and Tree Traversal - Recursive SQL 10 min read Pro lesson
- Median and Percentile Calculations - Beyond AVG 10 min read Pro lesson
- Overlap Detection and Date Ranges - Finding Conflicts 10 min read Pro lesson
- Pivot Patterns and Data Reshaping - Rows to Columns, Columns to Rows 10 min read Pro lesson
Module 17: Interview Strategy & Mock
Interview Strategy & Mock — 5 topics.
- How FAANG SQL Rounds Actually Run - Format, Scoring, and What They Do Not Tell You 10 min read Pro lesson
- Thinking Aloud Through a Query - The Skill That Gets You Hired 10 min read Pro lesson
- Clarifying Schema Before You Write - The Five Questions 10 min read Pro lesson
- Company Archetypes - What Meta, Amazon, and Netflix Actually Ask 10 min read Pro lesson
- The Capstone Mock - A Full End-to-End SQL Interview 11 min read Pro lesson