sushi&syntax
← SQL
rice · fundamentalslesson 01

What is SQL, actually?

Databases, tables and your very first question, explained with a sushi restaurant.

Imagine you run a sushi restaurant. Orders come in all evening: maki for table 5, nigiri for table 3, another maki for table 2. If you scribble them on random napkins, tomorrow you know nothing. Which dish sold best? No idea. The napkins are gone.

A database is the opposite of napkins. It is a place where information is written down so tidily that you can find anything again in a blink.

Everything lives in tables

Inside a database, information sits in tables. A table is just a grid, like a very disciplined notebook page:

ordersitemqtytablemaki25nigiri13temaki15one row =one orderthat happenedone column = one kind of fact (here: how many pieces)ordersitemqtytablemaki25nigiri13temaki15one row = one order that happenedone column = one kind of fact(here: how many pieces)
fig 1 · a table: rows are things that happened, columns are facts about them

Read it like this:

  • Every row is one thing that happened. One order, one customer, one sale.
  • Every column is one kind of fact. What was ordered, how many, for which table.

That is genuinely all a table is.

SQL is how you ask questions

You do not dig through the table yourself. You ask, and the database fetches. SQL (Structured Query Language, said as “sequel” or “ess-cue-ell”) is the language for asking:

you"show me all maki orders"the same thing, written precisely:SELECT * FROM ordersWHERE item = 'maki'databasemaki · tbl 5maki · tbl 2your answerYou never search the shelves yourself. You ask, the database fetches.you"show me all maki orders"the same thing, written precisely:SELECT * FROM ordersWHERE item = 'maki'databasemaki · tbl 5maki · tbl 2your answerYou never search the shelves yourself.You ask, the database fetches.
fig 2 · a query is a question: you ask, the database fetches, rows come back

The magic part: the same question works whether the table holds ten orders or ten million. You describe what you want, never how to find it. The database figures that out on its own.

What can you ask?

More than you would think. With a few words of SQL you can:

  • find things: all orders from table 5
  • count things: how many maki went out tonight?
  • sort things: the top three bestsellers
  • combine things: orders together with prices (that is a JOIN, a later lesson)

Where do you try it?

You do not need to install anything to start:

a playgroundin your browser,nothing to installstart herea tiny databaseone file on your disk:SQLite, DuckDBthe big kitchenservers running 24/7:Postgres, MySQLDifferent sizes, same language: they all speak SQL.a playgroundin your browser,nothing to installstart herea tiny databaseone file on your disk:SQLite, DuckDBthe big kitchenservers running 24/7:Postgres, MySQLDifferent sizes, same language:they all speak SQL.
fig 3 · three homes for SQL, smallest to biggest, all speaking the same language

Start in a browser playground. When that feels easy, a tiny database like SQLite or DuckDB lives happily as a single file on your laptop.

Try this yourself

Open an online playground (search for “SQLite online” or “DB Fiddle”) and type exactly this:

SELECT 'hello, kitchen!';

Press run. The database answers. That round trip, question in, answer out, is the entire game. Next lesson: asking for real rows with SELECT and WHERE.