SQL & Databases
Topic 1 ยท Getting started ยท โฑ about 30 min

SQL Course: Start Here

No experience needed. What a database is, what SQL does, the shop database you will practise on, how each lesson works, and your very first queries.

Show:
In this topic
Beginner

What is a database?

A database is an organised collection of data that many people and programs can use at the same time. Your bank balance, your online orders, your university enrolment and every app on your phone keep their data in databases.

Most business data lives in relational databases, which store data in tables. A table looks like a spreadsheet: each row is one thing (one customer, one order) and each column is one fact about it (name, city, date). Unlike a spreadsheet, every value in a column has the same type, and tables are linked to each other by keys.

SQL (Structured Query Language, said "S-Q-L" or "sequel") is the language for asking a database questions and changing its data. You describe what you want, and the database works out how to get it:

SELECT name, city FROM customers WHERE country = 'Australia';

That reads almost like English: "give me the name and city of the customers whose country is Australia".

Beginner

Why learn SQL?

  • It is everywhere. SQL has been the standard for 50 years and is used by nearly every company. Data analysts, data scientists, software engineers and AI engineers all use it, usually every day.
  • It is the first step of every data project. Before you can analyse data or train a model, you have to get the data out of a database, and that means SQL.
  • It is small. A dozen keywords cover most real work. You can be useful after a few weeks.
  • Interviews test it. SQL questions are part of almost every data and analyst job interview.
Beginner

The shop database you will use

Every lesson uses the same small database of an online shop, running right inside this page. It has four tables, linked by keys:

TableColumnsRows
customerscustomer_id (key), name, city (two are NULL), country, joined20
productsproduct_id (key), name, category, price15
ordersorder_id (key), customer_id โ†’ customers, order_date, statusabout 60
order_itemsorder_id โ†’ orders, product_id โ†’ products, quantity, unit_priceabout 150

An arrow (โ†’) means the column holds a key from another table: orders.customer_id says which customer placed the order. A few things are deliberately untidy, like real data: two customers have no city (NULL), some customers have never ordered, and some orders were cancelled.

Try it

Try it: your first queries

This is a real SQLite database in your browser. Press a preset, then โ–ถ Run. Then change something (a column name, a number) and run it again. You cannot break anything: Reset brings back the original data.

Interactive: this part runs in your browser.

Beginner

How each lesson works

  1. Read the idea in plain words, or press play at the bottom of the page to listen.
  2. Run the examples in the "Try it" boxes and change them.
  3. Practise. Each lesson ends with exercises: write a query, press โœ” Check my answer, and the page runs your query and compares the result with the correct one, telling you exactly what differs (missing rows, wrong columns, wrong order).
  4. Quiz to make sure the ideas stuck.

For more practice, there are SQL practice problems from easy to interview level, an SQL reference with every keyword and function, and the SQL playground with bigger databases. The next lesson shows how to set up SQL on your own computer.

Beginner

SQL dialects

There are many database systems: SQLite (inside phones, browsers and this page), PostgreSQL (the most popular open-source server), MySQL, Microsoft SQL Server, Oracle, and cloud warehouses like BigQuery and Snowflake. They all speak SQL, with small differences ("dialects"), mostly in date and text functions. About 90% of what you learn here works everywhere; where a difference matters, the lesson says so.

Beginner

Practice: check yourself

Write the query, then press โœ” Check my answer: your query runs on a fresh copy of the shop database and its result is compared with the correct one. โ–ถ Run just shows your result. Each run starts from the original data, so you cannot break anything.

Tables: customers(customer_id, name, city, country, joined) ยท products(product_id, name, category, price) ยท orders(order_id, customer_id, order_date, status) ยท order_items(order_id, product_id, quantity, unit_price)

Exercise 1. Every product

Show every column of every row in the products table.

Exercise 2. Names and countries

Show just the name and country of every customer.

Check yourself

Quiz

1. In a table, what is a row?

2. What does orders.customer_id hold?

3. Which statement about SQL is true?

Go deeper

๐Ÿ“š Further reading

Trusted, mostly free sources: official documentation, well-known textbooks and courses. When you want to confirm or go deeper on anything here, start with these.

Ready