Relational Databases: Tables, Rows, and Keys
A relational database stores data in tables. Each table holds one kind of thing — customers, products, orders.
Real-world analogy: a database is like a workbook of spreadsheets, but stricter. Each sheet (table) has fixed columns with fixed types, and sheets can refer to each other's rows by ID.
Rows and columns
customers
+----+----------------+-------------------+----------+
| id | name | email | city |
+----+----------------+-------------------+----------+
| 1 | Ada Lovelace | ada@example.com | London |
| 2 | Linus Torvalds | linus@example.com | Helsinki |
+----+----------------+-------------------+----------+
- A row (also called a record) is one item: one customer.
- A column (also called a field) is one piece of information about every item: every customer's email. Each column has a data type — text, number, date.
Primary keys
Each table usually has a primary key: a column whose value uniquely
identifies each row. Here, id is the primary key — two customers may
share a name, but never an id.
Foreign keys and relationships
Tables are connected through foreign keys — a column that holds the primary key of a row in another table:
orders
+----+-------------+------------+-----------+
| id | customer_id | ordered_on | status |
+----+-------------+------------+-----------+
| 1 | 1 | 2025-01-05 | delivered |
| 3 | 2 | 2025-02-20 | shipped |
+----+-------------+------------+-----------+
orders.customer_id refers to customers.id: order 1 belongs to
customer 1 (Ada). Instead of copying Ada's name and email into every one
of her orders, the database stores them once and relates the tables
— which is where "relational" comes from.
That design keeps data consistent (change Ada's email in one place, and every order reflects it) and saves space. Joining related tables back together in queries is one of SQL's core skills, covered in Level 2.
Database management systems
The software that runs a database is a DBMS. Popular relational ones include PostgreSQL, MySQL/MariaDB, SQLite, Microsoft SQL Server, and Oracle Database. They all speak SQL.