Part 01 / Topic 1 of 10
What a database is
A database is an organised collection of data that a program manages for you — storing it safely, finding it fast, and letting many users read and write it at the same time without stepping on each other.
You could keep an app's data in a plain file. Small scripts do. But files fall apart quickly in real systems:
| Problem with files | What a database gives you instead |
|---|---|
| Two users save at once — one overwrites the other | Safe concurrent access: both changes land |
| The app crashes mid-write — the file is half-written | Transactions: a change fully happens or fully doesn't |
| Finding one record means reading the whole file | Indexes: find one row among millions in milliseconds |
| Anyone with the file sees everything | Permissions: each user sees only what they may |
| "Is this field a number or text?" — nobody knows | A schema: every column has a declared type |
Real-world example: when you order food online, one database handles your order, the restaurant's menu, the rider's location and the payment state — thousands of people at once, with none of the orders lost or mixed up.
🧪 Quick quiz — answer from memory, then check.
- Name two things that go wrong when two users write to the same plain file.
- What does a transaction promise about a change?
Show the answers
- One user's save can overwrite the other's, and a crash mid-write can leave the file half-written.
- It fully happens or fully doesn't — you never keep half a change.
Done here? The practice set for Part 1 — 6 exercises with solutions — is on the part page.