Skip to content
SQL

SQL Course: Learn SQL and Databases From Beginner to Advanced

Ihsan Ullah · Updated · 5 min read
Free SQL course cover: 40 lessons in PostgreSQL with one practice database and real query results

Quick answer: This is a free, step-by-step SQL course in 40 short lessons, in a fixed order. You learn SQL on PostgreSQL with one small practice database (an online shop), and every lesson shows real queries, the real result, exercises with solutions, and the mistakes beginners usually make. Start with Lesson 1 and follow the “Next lesson” link at the end of each page.

The course goes from “what is a database?” to joins, window functions, database design, indexes, transactions and two projects. Where MySQL, SQLite or SQL Server write something differently, the lesson says so. New lessons are added in order; 25 of 40 are live now, and lessons that are not published yet are listed without a link.

Who this SQL course is for

  • Complete beginners who have never written a query.
  • Data analysts, data scientists and data engineers who need SQL every day.
  • Backend developers who want to understand the database behind their app.

You need a computer (Windows, macOS or Linux) and about 30 to 60 minutes per lesson. PostgreSQL and every other tool used here are free.

How to use this course

  1. Install PostgreSQL and load the shop practice database in Lesson 3. Every later lesson uses it.
  2. Type each query yourself, run it, and compare your result with the result shown.
  3. Do the “Try it yourself” exercises before you look at the solutions.
  4. Finish each level with its practice set or project before you move on.

SQL course outline

Level 1: Foundations

Module 1: Databases and setup

Module 2: Querying one table

Level 2: Core SQL

Module 3: Aggregation

Module 4: Joins

Module 5: Creating and changing data

Level 3: Intermediate

Module 6: Subqueries and CTEs

Module 7: Window functions

Module 8: Database design

  • Lesson 28: ER modeling: entities, relationships and keys (coming soon)
  • Lesson 29: Normalization: 1NF, 2NF, 3NF and BCNF with examples (coming soon)
  • Lesson 30: Normalization vs denormalization (OLTP vs analytics) (coming soon)

Level 4: Advanced

Module 9: Performance

  • Lesson 31: How database indexes work (B-tree, composite, covering, partial; PG index types) (coming soon)
  • Lesson 32: Reading EXPLAIN and EXPLAIN ANALYZE in PostgreSQL (coming soon)
  • Lesson 33: SQL query optimization checklist (sargable filters, statistics, join strategies) (coming soon)

Module 10: Concurrency

  • Lesson 34: Isolation levels, locks and deadlocks (coming soon)
  • Lesson 35: PostgreSQL JSONB and arrays for semi-structured data (coming soon)

Level 5: Production SQL and projects

Module 11: Production SQL

  • Lesson 36: Preventing SQL injection: parameterized queries, roles and GRANT (coming soon)
  • Lesson 37: Table partitioning for large tables (coming soon)

Module 12: Projects

  • Lesson 38: Project: sales analytics with SQL (cohorts, retention, funnels) (coming soon)
  • Lesson 39: Project: design and build an e-commerce database end to end (coming soon)
  • Lesson 40: SQL interview questions with worked answers (coming soon)

SQL first, then MongoDB

This page used to be a combined SQL and MongoDB roadmap. The advice has not changed: learn SQL first. Relational databases such as PostgreSQL and MySQL are what most data and backend jobs use, and the ideas you learn here (tables, keys, filtering, joins, indexes, transactions) make document databases much easier to understand later. MongoDB is a document database: it stores JSON-like documents instead of rows in tables. Learn it after this course if your work needs flexible, nested data; Lesson 35 (JSONB in PostgreSQL) shows how far a relational database can go with semi-structured data first.

Frequently asked questions

Is this SQL course free?

Yes. Every lesson is free to read on this site, and PostgreSQL, the practice database and the tools used in the course are free.

Which SQL should I learn first?

This course uses PostgreSQL, because it is free, follows the SQL standard closely and is widely used. The basics carry over to MySQL, SQLite and SQL Server; Lesson 2 compares them, and later lessons point out the differences that matter.

How long does it take to learn SQL?

There are 40 lessons, and most take 30 to 60 minutes with the exercises. The first two levels (about 19 lessons) cover the SQL most analyst jobs ask for, so at one lesson a day you can be productive in about three weeks.

Should beginners learn SQL or MongoDB first?

SQL first. It is needed in far more jobs, and it teaches the data ideas that make MongoDB and other NoSQL databases easier later.

Do I need programming experience to learn SQL?

No. SQL is a small language of its own, and this course assumes no programming background. If you also want Python for data work, the Python course starts from zero too.

Start the course

Begin with Lesson 1: What is a relational database?.

Ihsan Ullah

Written & tested by Ihsan Ullah

Data analyst with 3 years of experience and a Bachelor's degree in Computer Science. I write clear, practical guides on data, SQL, Python and AI.

More about me →

Leave a comment

Your email address will not be published. Required fields are marked *