A relational database keeps each fact once, in tables that refer to each other, with rules that keep it honest and a language, SQL, for asking it questions. What relational means, where a spreadsheet stops working, and why this design still runs the bank and the shop.
A relational database keeps facts in tables that refer to each other. Each fact is stored once, rules keep it honest, and you get answers by asking, in a language called SQL. Your bank balance, your contacts and your lunch order nearly all live in one.
The nearest thing most of us have used is a spreadsheet, one row per order and one column per detail. It works well until it outgrows what it was built for. The same customer gets typed three different ways, so nobody knows how many customers you have. Two people edit at once and a change is overwritten. Asking who ordered in March but not April means an afternoon of scrolling.
Each fact is stored once. A database splits the one sheet into tables, customers in one and orders in another. Every row gets its own number, called its key. The customer’s name and address are stored once, and each order points at the customer’s number. That’s what relational means. Each table is a relation, one kind of fact in one fixed shape, and the keys are how the tables refer to each other. When a customer with forty orders moves house, one row changes and not forty, so the address can’t disagree with itself.
You ask, you don’t scroll. SQL stands for Structured Query Language, and a query is a request for information. It’s structured because every question has the same three parts. You say what you want, where it lives and which ones you need. The database does the searching, and even with millions of rows the answer comes back in under a second.
Rules keep it honest. An order can’t point at a customer who doesn’t exist. Two people can’t save over each other’s changes. A change happens in full or not at all, so when a bank moves money between two accounts, it leaves one and lands in the other, or neither happens.
So a database isn’t a bigger spreadsheet. More than fifty years after it was designed, it still runs the bank, the shop and the booking system.
The facts come from Codd’s 1970 paper, the SQL standard, and the limits of a spreadsheet as its maker documents them. This is an independent explainer, not affiliated with any vendor.
The line to keepA spreadsheet is a page you look at. A database is something you ask.
Transcript of the video
Your bank balance, your contacts and your lunch order all live in a database, and nearly always the same kind, called relational. Before it, each program kept its data however it needed, in its own lists and files.
The nearest thing most of us have used is a spreadsheet, one row per order and one column per detail. A spreadsheet works well, right up until it outgrows what it was built for.
The same customer gets typed three different ways, so nobody knows how many customers you have. Two people edit at once, and a change can easily be overwritten. Asking who ordered in March but not April means an afternoon of scrolling.
A database starts by splitting that one sheet into tables. Customers in one, orders in another. Every row gets its own number, called its key. The customer's name and address are stored once. Each order points at the customer's number instead.
That's why it's called relational. Each table is a relation, which is one kind of fact in one fixed shape. The keys are how the tables refer to each other.
Now say a customer moves house. They've placed forty orders with you. How many rows have to change?
Only one row changes, and it belongs to the customer. The address lives in one place, and every order refers to it by number. That's the first thing you get from a database. Each fact is stored once, so it can't disagree with itself.
The second thing is how you get answers. Instead of scrolling, you ask the database directly. The way you ask is called SQL, which stands for Structured Query Language. A query is just a request for information.
It's called structured because every question has the same three parts. You say what you want, where it lives, and which ones you need. The database does the searching and hands back the rows. Even with millions of rows, the answer comes back in under a second.
The third thing is rules. An order can't point at a customer who doesn't exist. Two people can't save over each other's changes. A change either happens in full or not at all. When a bank moves money between two accounts, it leaves one and lands in the other, or neither happens. It never stops halfway.
So a database isn't a bigger spreadsheet. A spreadsheet is a page you look at, and a database is something you ask.
Every fact is stored once, the answers come back instantly, and the numbers add up. That is why, more than fifty years on, it still runs the bank, the shop and the booking system.
A relational database is facts in tables that refer to each other. Each fact is stored once, and rules keep it honest. Ask with SQL, and you get a clear answer.
Found this useful?
Subscribe for the next one, or tell me what you want explained. I take requests.