Free preview
What databases and SQL are
Reading · 12 min
A database is an organised collection of data that a computer can store, search and update quickly and reliably. Your bank, your school's records, an online shop's orders and your phone's contacts all live in databases.
Why not just use a spreadsheet?
Spreadsheets are excellent for small, personal data. Databases take over when:
- the data is large: millions of rows that would make a spreadsheet crawl,
- many people or apps need to read and change it at the same time,
- the data must stay consistent: an order can't refer to a customer who doesn't exist,
- you need to answer questions repeatedly and automatically, for example in an app.
Relational databases
The most common kind is the relational database. Data is stored in tables, which look a lot like spreadsheet sheets:
| id | name | city |
|---|---|---|
| 1 | Ada Okafor | Lagos |
| 2 | Kwame Mensah | Accra |
| 3 | Grace Wanjiru | Nairobi |
- Each row is one record (one customer).
- Each column is one piece of information with a fixed type (text, number, date).
- A primary key (here
id) uniquely identifies each row.
The "relational" part is that tables are linked. An orders table can store customer_id = 2 instead of copying Kwame's name and city into every order. That link is a relationship, and it's what keeps data tidy.
SQL
SQL (Structured Query Language, often said "sequel") is the language for working with relational databases. You describe what you want, and the database works out how to get it:
SELECT name, city
FROM customers
WHERE city = 'Lagos';That's close to plain English: "select the name and city from customers where the city is Lagos".
One language, many databases
| Database | Typical use |
|---|---|
| SQLite | A single file; built into phones, browsers and many apps. Perfect for learning |
| PostgreSQL | Powerful open-source server database used by many startups |
| MySQL / MariaDB | Very common for websites |
| Microsoft SQL Server | Popular in large organisations |
The core of SQL is the same in all of them. Each has small differences, which we'll point out where they matter. This course uses SQLite because it's free and needs no server.
Try it
Spot the tables
Think of an app you use, such as a food delivery app. Write down three tables it probably has, and four columns for each. Which columns would link the tables together?
Like this lesson?
SQL & Database Fundamentals has 17 lessons with exercises, quizzes and a final project.