Course · 06
SQL Fundamentals
Query a real PostgreSQL database that runs in your browser. Filter, sort and summarize rows, join tables, write subqueries, translate relational algebra, design and normalize a schema, then add views, procedures, indexes, transactions and access control. Every table is on screen while you work, and every lab checks your query the moment you run it. Nothing to install.
- 16
- chapters
- 232
- lessons & labs
- Chapter 1
- free, no account needed
- Nothing to install
- PostgreSQL runs in your browser
Who it's for
Students in a database course, and engineers who query every day.
- Computer science students taking a database course (relational model, SQL, ER design, normalization)
- Developers and SREs who use a database every day but learned SQL by copying queries
- Anyone preparing for a technical interview with SQL questions
What you'll be able to do
Query, design and run a relational database with confidence.
- Write SELECT queries that filter, sort, group and summarize data
- Combine tables with inner, outer and self joins, subqueries and set operations
- Translate relational algebra expressions to SQL and back
- Design a schema from an ER model and normalize it to 3NF and BCNF
- Create tables with keys and constraints, and change data safely
- Use views, functions, procedures, indexes, transactions and roles
The path
16 chapters covering queries, joins, schema design, performance and access control.
Each lesson is short and ends in a quiz, then a lab on a real PostgreSQL database in your browser, with every table on screen. Chapter 1 is free.
01
First Queries
Read a table with SELECT
3 lessons · 5 labsFree02
Filter Rows
Keep only the rows you need with WHERE
6 lessons · 7 labs- 1WHERE4 min
- 2Keep the Rows You NeedLab5 min
- 3Comparison Operators3 min
- 4Compare ValuesLab5 min
- 5AND, OR and NOT4 min
- 6Combine ConditionsLab6 min
- 7IN and BETWEEN3 min
- 8Lists and RangesLab5 min
- 9LIKE Patterns4 min
- 10Match a PatternLab5 min
- 11NULL4 min
- 12Find the Missing ValuesLab5 min
- 13Challenge: Filter the ShopLab8 min
03
Sort and Shape Results
Order, limit and compute the columns you return
6 lessons · 7 labs- 1ORDER BY4 min
- 2Sort the RowsLab5 min
- 3LIMIT and OFFSET3 min
- 4Top Rows and PagesLab5 min
- 5DISTINCT3 min
- 6Remove DuplicatesLab4 min
- 7Expressions and Aliases4 min
- 8Calculate and Name ColumnsLab5 min
- 9Functions4 min
- 10Use FunctionsLab6 min
- 11CASE3 min
- 12Label the RowsLab5 min
- 13Challenge: Shape the ReportsLab8 min
04
Create Tables
Define tables, add rows and change a schema
8 lessons · 8 labs- 1CREATE TABLE4 min
- 2Create Your First TableLab5 min
- 3Data Types4 min
- 4Choose the TypesLab6 min
- 5INSERT a Row4 min
- 6Fill a TableLab6 min
- 7NOT NULL and DEFAULT4 min
- 8Required Values and DefaultsLab6 min
- 9Identity Columns4 min
- 10Let the Database Number RowsLab6 min
- 11ALTER TABLE4 min
- 12Change a Table That Holds DataLab6 min
- 13DROP TABLE3 min
- 14Clean Up the SchemaLab5 min
- 15Schema Migrations4 min
- 16Write an Up and a DownLab7 min
05
Keys and Constraints
Let the database refuse bad data
7 lessons · 7 labs- 1Primary Keys4 min
- 2One Row, One KeyLab5 min
- 3Superkeys and Candidate Keys4 min
- 4Find the KeysLab6 min
- 5UNIQUE4 min
- 6No Two the SameLab6 min
- 7CHECK4 min
- 8Only Valid ValuesLab6 min
- 9Foreign Keys4 min
- 10Links That HoldLab6 min
- 11ON DELETE4 min
- 12Choose What a Delete DoesLab7 min
- 13Composite Keys4 min
- 14A Key of Two ColumnsLab6 min
06
Change Data
Insert, update and delete rows without surprises
6 lessons · 6 labs07
Summarize Data
Count, total and average rows in groups
7 lessons · 7 labs- 1COUNT3 min
- 2Count Rows and ValuesLab4 min
- 3SUM and AVG3 min
- 4Totals and AveragesLab5 min
- 5MIN and MAX3 min
- 6Smallest and LargestLab4 min
- 7GROUP BY4 min
- 8One Row per GroupLab5 min
- 9GROUP BY Several Columns3 min
- 10Groups of CombinationsLab4 min
- 11HAVING3 min
- 12Keep Some GroupsLab5 min
- 13WHERE vs HAVING4 min
- 14Rows First, Then GroupsLab5 min
08
Join Tables
Combine rows from related tables
10 lessons · 10 labs- 1How Tables Relate3 min
- 2Follow the LinksLab4 min
- 3INNER JOIN4 min
- 4Join Two TablesLab5 min
- 5Table Aliases3 min
- 6Use Table AliasesLab4 min
- 7LEFT JOIN4 min
- 8Keep Every RowLab5 min
- 9RIGHT and FULL JOIN3 min
- 10Right and Full JoinsLab4 min
- 11Self Join3 min
- 12Employees and ManagersLab4 min
- 13Join Many Tables4 min
- 14Follow the ChainLab6 min
- 15CROSS JOIN3 min
- 16Every PairLab4 min
- 17Joins and Groups4 min
- 18Totals Across TablesLab6 min
- 19NATURAL JOIN and USING4 min
- 20Shared Column NamesLab5 min
09
Subqueries and Set Operations
Queries inside queries, and UNION, INTERSECT, EXCEPT
9 lessons · 9 labs- 1Scalar Subqueries4 min
- 2One Value Inside a QueryLab5 min
- 3IN (subquery)3 min
- 4Membership TestsLab5 min
- 5NOT IN and NULL4 min
- 6The NULL TrapLab5 min
- 7EXISTS4 min
- 8Is There a Row?Lab5 min
- 9ALL, ANY and SOME3 min
- 10Every or At Least OneLab4 min
- 11Subqueries in FROM4 min
- 12Query a QueryLab5 min
- 13WITH4 min
- 14Name the StepsLab5 min
- 15UNION4 min
- 16Combine ResultsLab5 min
- 17INTERSECT and EXCEPT4 min
- 18Both or Only OneLab5 min
10
Relational Algebra
The operators under every SQL query
10 lessons · 10 labs- 1Relational Algebra4 min
- 2Read the ExpressionsLab3 min
- 3Selection σ3 min
- 4Translate SelectionsLab4 min
- 5Projection π3 min
- 6Translate ProjectionsLab4 min
- 7Rename ρ3 min
- 8Translate RenamesLab4 min
- 9Cartesian Product ×4 min
- 10Translate ProductsLab5 min
- 11Joins ⋈4 min
- 12Translate JoinsLab5 min
- 13Set Operations ∪ ∩ −3 min
- 14Translate Set OperationsLab6 min
- 15Division ÷4 min
- 16Translate DivisionLab6 min
- 17Grouping γ3 min
- 18Translate GroupingLab4 min
- 19Translate Expressions4 min
- 20Translate ExpressionsLab6 min
11
Design a Database
ER models, relationships and normal forms
10 lessons · 11 labs- 1Entities and Attributes4 min
- 2Find the AttributesLab4 min
- 3Relationships and Cardinality4 min
- 4Read Cardinality from DataLab5 min
- 5ER to Tables4 min
- 6Build Tables from an ER ModelLab6 min
- 7Weak Entities3 min
- 8Store a Weak EntityLab5 min
- 9Anomalies3 min
- 10Cause the AnomaliesLab5 min
- 11Functional Dependencies5 min
- 12Test Functional DependenciesLab6 min
- 13First Normal Form3 min
- 14Remove a Repeating GroupLab6 min
- 15Second Normal Form4 min
- 16Remove a Partial DependencyLab6 min
- 17Third Normal Form4 min
- 18Remove a Transitive DependencyLab6 min
- 19Boyce-Codd Normal Form5 min
- 20Decompose into BCNFLab7 min
- 21Normalize a TableLab10 min
12
Views, Functions and Procedures
Keep queries and logic inside the database
6 lessons · 6 labs13
Indexes and Performance
Read query plans and make slow queries fast
6 lessons · 6 labs14
Transactions
All or nothing, even when things fail
8 lessons · 8 labs- 1BEGIN and COMMIT4 min
- 2Move Money in One TransactionLab5 min
- 3ROLLBACK3 min
- 4Undo a MistakeLab4 min
- 5Atomicity4 min
- 6All or NothingLab5 min
- 7ACID4 min
- 8Name the PropertyLab4 min
- 9SAVEPOINT4 min
- 10Keep the Good PartLab5 min
- 11Concurrency Problems4 min
- 12Replay a Lost UpdateLab5 min
- 13Isolation Levels4 min
- 14Choose an Isolation LevelLab4 min
- 15Locks4 min
- 16Lock Before You WithdrawLab4 min
15
Database Security
Roles, privileges and least privilege
6 lessons · 7 labs16
Beyond Relational
JSON documents and when NoSQL fits
5 lessons · 5 labs
