Databases · Lesson 3.1
What goes in a row?
A relational database keeps its data in tables of rows and columns, like your phone's contacts.
Simplified, the app you're learning on, keeps its data in a relational database called Postgres.
Postgres is a database: a program that keeps Simplified's data on disk, in tables.
When you signed up, Postgres stored your email and your name.
And each time you finish a lesson, it stores the XP you earn.
So how does Postgres keep your email, your name and your XP together?
Well, think of your Instagram profile.
It keeps your facts together: your username, your name and your bio.
Your Spotify account does the same, with your email and your name.
And a friend's contact on WhatsApp keeps their name and phone number together.
Each one is one person's facts, kept together.
Postgres keeps Simplified's learners the same way, in a table called users.
Each learner's email, name and XP sit together, on one line.
Like one contact in your contacts table, that line is a row.
A row is one of the things a table holds: here, one learner.
And a table holds one kind of thing, so users holds only learners.
Simplified's lessons are a different kind of thing, so they sit in a table of their own.
So what happens when a new learner signs up?
Say that early on, only five learners had signed up: Ada, Ben, Cy, Dee and Eli.
So users held five rows, one for each of them.
Then Fay signed up, with fay@simplified.org.
Simplified's server sent Postgres her email and her name, and Postgres stored them in one new row.
She hadn't finished a lesson yet, so her XP was 0.
So users then held six rows, one for each of its six learners.
And what happens when you open your Learn page on Simplified?
Say Simplified has 2,000,000 learners, so users holds 2,000,000 rows.
One of those rows is yours.
Simplified's server sends Postgres a query, asking for your row.
Postgres finds it among the 2,000,000, and sends back that one row.
It holds your email, your name and your XP, all together.
So the XP on your Learn page came from your row.
So a table holds one kind of thing, like Simplified's learners.
And each row is one of them, with all of its facts kept together.
Say Simplified's users table holds 6 rows, one for each learner. Then Jay signs up.
How many rows does users hold now?
Explanation
First, each learner has exactly one row in users.
Then, Jay is one new learner, so Postgres stores his facts in one new row.
Therefore, users holds 7 rows.
Instagram might keep its accounts in one table, one row for each account. Your profile shows your username, your name and your bio.
What is your profile in that table?
Databases · Lesson 3.2
Where a row meets a column
Simplified's users table holds a row for each learner, and every row has an email, a name and XP.
So how does every learner's row end up with the same kinds of facts?
Well, think back to when you signed up for Simplified.
The sign-up form had a box for your email, and a box for your name.
Every learner filled in those same two boxes, with their own answers.
So users keeps each box's answers in one strip, running down every row.
Like the phone numbers in your contacts table, each of those strips is a column.
A column is one fact that every row has, like email.
So which columns does users have?
Two come from the form: email and name.
Simplified adds an XP column itself, for the XP each learner earns.
And a column called created at holds when each learner signed up.
Then there's ID, a number no other learner has, like a contact's ID.
We'll see where each learner's id comes from in a later lesson.
So where exactly is Ada's email?
Start at Ada's row, then go across to the email column.
Where they cross, one box holds ada@simplified.org.
That box is called a cell.
A cell is one row's value for one column.
Ben's XP is a cell too: Ben's row, the XP column, 40.
And Dee's sign-up date is where Dee's row meets created at: 2026-03-02.
So every row has the same columns, one for each kind of fact.
And each cell holds one value: one row's fact for one column.
Spotify might keep its accounts in a table with the columns id, email, name and country. Your row holds your email, your name and the country USA.
Where exactly is USA kept?
Explanation
First, USA is one of your facts, so it's in your row.
Then, it's your country, so it's in the country column.
Therefore, USA is in the cell where your row meets the country column.
Say Todoist keeps its tasks in a table with 3 columns: title, due date and project. It holds 8 tasks, one row each.
How many cells does one task's row hold?
Instagram might keep its accounts in a table, one row for each account. Every account has a username, a name and a bio.
In that table, what is bio?
Say YouTube keeps its videos in a table, one row for each video, with a views column for how many times each video was watched. One video's row holds 1,200 in the views column.
What is that 1,200?
Duolingo's sign-up form asks for your age, your name and your email. Say Duolingo keeps its learners in a table, one row for each learner.
Where would every learner's age go?
Simplified's users table has the columns id, email, name, xp and created_at, one row for each learner. One more learner signs up.
What changes in the table?
Say Netflix keeps its profiles in a table with the columns name, language and avatar, one row for each profile. Your profile's language is Spanish.
Where exactly is Spanish kept?