Module lessons (1/4)
Introduction to SQL
What is SQL
SQL (Structured Query Language) is the standard language for reading and manipulating data inside a relational database. Born in the 1970s in IBM's labs, today it is spoken by virtually every application that stores structured data: business software, e-commerce, social networks, banking apps, analytics dashboards. Learning SQL is what separates "I use a database" from "I command a database".
In this course we will learn SQL interactively: nothing to install, no account required. Every exercise runs on a real PostgreSQL that lives inside your browser tab. When you press Verify, your query is actually executed against a real database — there is no simulation.
A database in 30 seconds
A relational database is a set of tables. A table is like a structured spreadsheet:
- each row is a record (e.g. an employee, an order, a book);
- each column is an attribute of that record (name, salary, price);
- each column has a type (text, number, date, boolean…) and the database rejects values of the wrong type.
Tables do not live in isolation: they have relationships between them. For example, every employee belongs to a department; every project involves multiple employees. SQL lets us query tables, filter them, sort them and — as we will see later — follow their relationships.
Our dataset
Throughout Module 1 we will use a dataset called employees, a small
fictional company with four tables:
departments— the departments (e.g. Engineering, Sales).employees— the employees, with name, email, salary, hire date.projects— the company's projects, with a budget.assignments— who works on which project, with a role.
In the exercises you will always find it already loaded. You can also explore it freely from the Playground to try queries without having to solve anything.
Three things to know up front
Before writing your first query, three rules that will be useful in every lesson:
- Keywords are not case-sensitive:
SELECTandselectare equivalent, but by convention we write them in UPPERCASE to distinguish them from table and column names. - Strings go between single quotes:
'Milano', not"Milano". Double quotes are for column/table names (rarely needed). - Every statement ends with
;. In exercises you can omit it, but writing it is a good habit — it becomes mandatory when you run multiple queries in a row.
What you will learn
In Module 1 we will cover the foundations of reading data:
SELECT … FROM— read rows from a table.WHERE— filter rows.ORDER BY— sort the results.
In Module 2 we raise the bar with LIMIT, DISTINCT, aliases and
aggregate functions. Later on JOIN and GROUP BY will arrive, and with
those you will master 90% of the SQL used in real-world work.
Ready? Press Next lesson at the bottom of the page to begin.