Portmint Lighthouse

Tables, Rows, and Columns

Every database, no matter how grand, is built from three small words — table, row, and column. Learn these three and most of the mystery falls away. You already know them, in fact; you just haven't named them yet.

Picture a metal filing cabinet. It has several drawers, and each drawer holds one kind of paperwork — one drawer for clients, one for invoices, one for suppliers. You'd never toss an invoice into the client drawer; you'd lose your mind finding anything later. That cabinet is our whole picture today.

A table is one drawer

A table is a single drawer. It's one grid about one kind of thing: a table called customers holds customers, and only customers. A table called orders holds orders.

The name on the front of the drawer tells you what's inside, and keeping each kind of thing in its own drawer is the first habit of a tidy database — the same way you keep socks and spoons apart. One drawer, one kind of thing.

A row is one folder

Open the customer drawer and pull out a single folder. That folder is everything about one customer — her name, her email, her town, all together in one place.

A row is that folder. It's one complete thing, one record, read straight across. People often call a row a "record," because it's the full record of a single item. Three hundred customers means three hundred folders — three hundred rows. Add a new customer and the database simply adds a new folder to the drawer.

A column is one fact, repeated

Now look at the same line across every folder. Every customer folder has an "email" line. The email is different each time, but the kind of fact is identical down the whole drawer.

A column is that one fact, running top to bottom through every row. "Email" is a column. "Town" is a column. A row reads across; a column runs down.

Here's the part a plain spreadsheet won't do for you. A database lets you tell each column what type of fact it holds — this one is text, that one is a whole number, this one is a date. Once you've said so, the database stands quiet guard. Tell the "joined" column it holds dates, then try to type "banana" into it, and the database refuses. It's a slot shaped only for dates; the wrong shape won't fit. That refusal is a gift — it catches the typo before it becomes tomorrow's mystery.

Same shape, real names

Let's name a tiny customers table out loud. Columns: name, email, town. Row one: Ada, ada@example.com, Albany. Row two: Ben, ben@example.com, Boston. Two rows, three columns, six little cells — and it reads exactly like a page from an address book.

So the whole thing is small. A table is one drawer about one kind of thing. A row is one folder, one full record inside it. A column is one fact, the same kind, repeated down every row, with a type the database enforces. Drawer, folder, fact.

Your turn

Open any spreadsheet you have — a contact list, a budget, anything with a header row.

  1. What single kind of thing is this table about? Say it in one word.
  2. Point at one row. Whose complete story is it telling?
  3. Pick one column. What single fact does it hold, and what type is it — text, a number, or a date?

Answer all three and you've read a database in the language it actually speaks.

Next we'll face the trouble that shows up when the same fact starts appearing in more than one place. 🔦

Stuck or curious?

Ask Pip about this lesson — tap the porthole bottom-right.