By the end of this lesson you can explain what a database and SQL are, and run a statement that shows every row of a table.
Why it matters: Almost every organisation keeps its records (customers, sales, payments, staff) in databases, and SQL is the common language for asking them questions. Analysts, finance teams, product managers and developers all use it daily.
Dataset: Starter shop. Examples run in the editor on the right.
A database is an organised, permanent store of records. Think of the records a small shop keeps: who its customers are, what it sells, and who bought what. On paper that would be three ledgers. In a database it's three tables.
A table looks like a spreadsheet tab: it has named columns across the top (for example customer_name and city) and one row for each record (one row per customer). Unlike a spreadsheet, a database is strict: every column holds one kind of value, every table has a fixed name, and the database keeps the data consistent even when thousands of people use it at once.
The program that stores the tables and answers questions about them is a database management system (DBMS). In SQL Quest you use PostgreSQL, one of the most widely used database systems in the world. It runs right in your browser, on a copy of the data, so you can't break anything.
SQL: the language you ask in
SQL (Structured Query Language, said ess-cue-ell or sequel) is how you talk to a relational database. One complete instruction is a statement. The statements you'll write most often are queries: questions that read data and return an answer, without changing anything.
SQL is declarative: you describe what you want, not how to fetch it. You don't tell PostgreSQL which file to open or how to loop through rows. You say "show me every customer", and the database works out the fastest way to do it.
Here is a complete statement. Run it: it is the classic first look at a table.
SELECT *
FROM customers;PostgreSQL reads the customers table and returns every row and every column. The result has 12 rows (one per customer) and 5 columns. Nothing in the table changes: a query only reads.
Read that statement word by word:
SELECTmeans return some columns.*(asterisk) is shorthand for all of the columns.FROM customerssays which table to read.;ends the statement.
The answer comes back as a result: a temporary table built just for your question. You'll learn to choose specific columns in a later lesson. For now, SELECT * FROM table_name; is your window into any table.
SELECT *
FROM table_name;The starter database: Corner Market
Your first lessons use Corner Market, a fictional online shop with three small tables you can read in full:
| table | one row is… |
|---|---|
customers | a person registered with the shop |
products | an item the shop sells |
orders | one order: a customer buying one product |
The schema panel next to the editor lists these tables and their columns. Keep it open: professionals look at the schema constantly.
SELECT *
FROM products;Returns the 10 products with all five of their columns: an id number, the name, the category, the price in SAR and the units in stock. One row per product.