SQL: complete course
Master relational data modeling, querying, joins, aggregation, constraints, indexes, transactions and production database thinking. Every chapter ends with practical projects so you build while you learn.
1Relational databases and SQL~10 min
What you are learning
1 Relational databases and SQL ~10 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
CREATE TABLE courses (id INTEGER PRIMARY KEY, title TEXT NOT NULL);Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
2CREATE TABLE and data types~12 min
What you are learning
2 CREATE TABLE and data types ~12 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
CREATE TABLE students (id INTEGER PRIMARY KEY, name TEXT NOT NULL, age INTEGER, joined_at TIMESTAMP);Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
3INSERT and data changes~14 min
What you are learning
3 INSERT and data changes ~14 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
INSERT INTO courses (id, title) VALUES (1, 'HTML');
UPDATE courses SET title = 'HTML Foundations' WHERE id = 1;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
4SELECT fundamentals~16 min
What you are learning
4 SELECT fundamentals ~16 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
SELECT id, title FROM courses;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
5Filtering and sorting~18 min
What you are learning
5 Filtering and sorting ~18 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
SELECT * FROM courses WHERE title LIKE 'HTML%' ORDER BY title ASC;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
6Aggregate functions~20 min
What you are learning
6 Aggregate functions ~20 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
SELECT COUNT(*) AS total_courses, MAX(id) AS highest_id FROM courses;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
7GROUP BY and HAVING~22 min
What you are learning
7 GROUP BY and HAVING ~22 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
SELECT level, COUNT(*) AS total FROM courses GROUP BY level HAVING COUNT(*) > 1;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
8Relationships and foreign keys~24 min
What you are learning
8 Relationships and foreign keys ~24 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
CREATE TABLE progress (student_id INTEGER REFERENCES students(id), course_id INTEGER REFERENCES courses(id), PRIMARY KEY (student_id, course_id));Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
9JOINs~26 min
What you are learning
9 JOINs ~26 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
SELECT students.name, courses.title FROM students JOIN progress ON progress.student_id = students.id JOIN courses ON courses.id = progress.course_id;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
10Subqueries and CTEs~28 min
What you are learning
10 Subqueries and CTEs ~28 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
WITH completed AS (SELECT course_id FROM progress) SELECT course_id FROM completed;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
11Views and reusable queries~30 min
What you are learning
11 Views and reusable queries ~30 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
CREATE VIEW course_list AS SELECT id, title FROM courses;
SELECT * FROM course_list;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
12Indexes and query performance~32 min
What you are learning
12 Indexes and query performance ~32 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
CREATE INDEX idx_courses_title ON courses(title);
EXPLAIN SELECT * FROM courses WHERE title = 'HTML';Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
13Transactions and concurrency~34 min
What you are learning
13 Transactions and concurrency ~34 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
BEGIN;
UPDATE courses SET title = 'CSS' WHERE id = 1;
COMMIT;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
14Constraints and data integrity~36 min
What you are learning
14 Constraints and data integrity ~36 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT UNIQUE NOT NULL);
ALTER TABLE progress ADD CONSTRAINT fk_student FOREIGN KEY (student_id) REFERENCES users(id);Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
15Advanced querying~38 min
What you are learning
15 Advanced querying ~38 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
SELECT title, COUNT(*) OVER () AS total_rows FROM courses ORDER BY title;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
16Database design and application integration~40 min
What you are learning
16 Database design and application integration ~40 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
-- Application query shape
SELECT c.id, c.title, COUNT(p.student_id) AS learners
FROM courses c LEFT JOIN progress p ON p.course_id = c.id
GROUP BY c.id, c.title;Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example
17Capstone: production database~42 min
What you are learning
17 Capstone: production database ~42 min is a core part of SQL. Learn the vocabulary, syntax, execution or data model, why the feature exists, how it interacts with earlier concepts, and the mistakes that cause real programs to fail.
How it works
Practice the smallest useful version first, then change inputs, combine it with earlier concepts, and inspect what happens when assumptions are wrong. Production code favors clear, testable solutions over clever tricks.
Practical example
CREATE TABLE enrollments (student_id INTEGER NOT NULL, course_id INTEGER NOT NULL, enrolled_at TIMESTAMP NOT NULL, PRIMARY KEY(student_id, course_id));Practice: Change one part of the example, predict the result, run it when supported, then deliberately make one small mistake and fix it.
Projects
Do these after the explanation. Do not copy the example unchanged; build the projects from memory and use the reference only when stuck.
- Build a focused SQL mini-project
- Build a second project combining this chapter with earlier concepts
- Rebuild the project without copying the example