Summary — The Whole Chapter in a Glance
- A database is an organised collection of data, made of one or more tables, stored on secondary storage.
- Databases beat plain text files once your data gets large — they're faster to search, more secure, and multiple people can use them at once.
- A field = one column = one piece of information. A record = one row = all the info about one item/person.
- Validation rules (length, format, range, presence, type, check digit) control what data is allowed into a field — they stop nonsense being entered, but don't check if it's actually true.
- Every field has a data type (integer, real, text, character, date/time, Boolean) that matches the kind of data it stores.
- A primary key is a unique field used to identify each record — no two records can ever share one.
1. Single Table Databases
What actually is a database?
Think of a database as a giant, super-organised filing cabinet. Instead of loose paper stuffed into folders,
everything is arranged into neat tables — and each table is arranged into rows and columns, a bit like a
spreadsheet. This structure is what makes a database so powerful: because the computer knows exactly where every piece
of data lives, it can find, sort, and update information almost instantly, even if there are millions of entries.
A database is made up of one or more tables, and each table is built from fields (the columns)
and records (the rows). Databases are stored on secondary storage (like a hard drive or SSD)
because they're usually too big — and too important to lose — to just live in RAM. Many databases also live on
remote servers, so lots of different people (think: hundreds of customers on an online shop) can access
and use the same data at the same time.
Why use a database instead of a text file?
Because a database is
secure,
efficient to search/sort (it can use smart structures
like indexes), and it can handle
large amounts of data reliably — whereas a text file gets messy,
slow, and insecure once the data grows.
Databases vs. Text Files — what's the real difference?
This is a classic exam comparison, so let's nail it properly. A text file is fine for small amounts
of data — it's just a plain list where each entry sits on its own line, or entries are separated by something like a
comma. The problem is that a text file has no real structure. The computer doesn't inherently know
where one record ends and another begins — it's just guessing based on line breaks or commas. If your data is messy
(say, someone's address contains a comma), a text file can get confused about where fields start and stop.
secure
search and sort
large-scale, multi-user
| Feature | Text File | Database |
| Best for | Small amounts of data | Large amounts of data |
| Structure |
| Security |