In this lesson: Understand tables, keys and what SQL is for.
SQL (Structured Query Language) is how you talk to a relational database. You describe what you want; the database works out how to get it.
Tables
Data lives in tables — like a spreadsheet, but with strict rules. Here is a students table:
| id | name | country | mark |
|---|---|---|---|
| 1 | Aline Uwase | Rwanda | 91 |
| 2 | Eric Nsengi | Rwanda | 64 |
| 3 | Grace Achieng | Kenya | 78 |
- Each column holds one kind of value and has a fixed type.
- Each row is one record — one student.
Common column types
INT whole numbers
DECIMAL(10,2) exact decimals — use this for money
VARCHAR(191) text up to a length
TEXT long text
DATE 2026-09-05
DATETIME 2026-09-05 14:30:00
BOOLEAN true / false
DECIMAL, or store whole cents in an INT.
Primary keys
Every table should have a column that uniquely identifies each row — usually id. That is the primary key. It cannot be null and cannot repeat.
Foreign keys — how tables relate
A second table, enrolments, points at students by their id:
| id | student_id | course |
|---|---|---|
| 1 | 1 | Web development |
| 2 | 1 | SQL |
| 3 | 3 | Networking |
student_id is a foreign key: it must match an id in students. This is what "relational" means, and it is what stops you ending up with an enrolment for a student who does not exist.
The four things you will do
SELECT read rows
INSERT add rows
UPDATE change rows
DELETE remove rows
Keywords are conventionally written in capitals. SQL does not care, but it makes queries far easier to read.