What Is a Database?
Definition
Database
- In plain English
- A database is software that stores data safely and lets programs find and change it quickly.
- Think of it like
- It is like a library with a catalogue, where books survive the night and the librarian finds any one in seconds.
Persistence
- In plain English
- Persistence means data survives after the program stops or the machine restarts.
- Think of it like
- It is like writing in ink instead of on a steamed-up window.
Relational database
- In plain English
- A relational database stores data in tables of rows and columns and links tables using shared values.
- Think of it like
- It is like a set of spreadsheets where one sheet's customer number points to a row in the customers sheet.
Why it exists
You record ten bags of blood in server memory. A power cut erases the count during the next shift.
A file can survive a restart. But coordinating two writers and searching thousands of records needs extra code.
How it works
CRUD
- In plain English
- CRUD stands for create, read, update and delete, the four basic things programs do with data.
- Think of it like
- Like adding, reading, editing and shredding index cards.
Query
- In plain English
- A query is a request asking the database for specific data.
- Think of it like
- Like asking the librarian for every book by one author.
| Store | Survives restart? | Many writers? | Search? |
|---|---|---|---|
| Program memory | No | Needs coordination | You build the lookup |
| Plain file | Yes, after saving safely | You coordinate access | You build the search |
| Database | With durable settings | Coordinates supported writes | Built-in query tools |
- Ask
Your app sends a query to read or change data.
- Check
The database checks the request and finds the matching records.
- Save or return
Reads return records, called rows in a table. Durable writes reach persistent storage before confirmation.
An app sends a query to a database, which saves writes to disk and returns results to the app.
SQL
- In plain English
- SQL is the standard language for asking a relational database to read and change data.
- Think of it like
- It is like a precise order form every relational database understands.
Examples
Keep the stock count
Your stock count must survive a power cut halfway through a shift.
Use durable storage settings. The database can first save a recoverable record of the change, then confirm success.
A restart recovers confirmed changes from storage. Protect against disk loss with separate copies and backups too.
The insight
Persistence is the first job of a database.
Follow a wristband balance
You create a cashless wristband record at purchase. Staff read it, update top-ups, and remove it after refunds.
INSERT INTO wristbands (id, balance) VALUES (9142, 20);
SELECT balance FROM wristbands WHERE id = 9142;
UPDATE wristbands SET balance = balance + 10 WHERE id = 9142;
DELETE FROM wristbands WHERE id = 9142;A table groups records with named fields, such as id and balance. Keep financial history separately after refunding a wristband.
The insight
Almost every feature is some mix of CRUD.
Find one station’s readings
Your 5,000 stations each send one reading every minute. Scientists request the last 24 hours for station 42.
INSERT INTO readings (station_id, recorded_at, temperature_c)
VALUES (42, TIMESTAMP '2026-11-22 12:00:00', 18.5);
SELECT recorded_at, temperature_c
FROM readings
WHERE station_id = 42
AND recorded_at >= TIMESTAMP '2026-11-21 12:00:00'
AND recorded_at < TIMESTAMP '2026-11-22 12:00:00'
ORDER BY recorded_at;At a steady rate, 5,000 × 1,440 gives 7,200,000 readings per day. The station and time conditions select the relevant records.
The insight
How you query the data shapes how it should be stored.
Trade-offs
Pros
- Coordinates many writers.
- Provides search tools.
- Durable settings protect confirmed writes.
Cons
- Another system to operate.
- Requires learning and storage costs.
Use when
- Shared data must survive restarts.
- Several programs change the same records.
Avoid when
- A one-off script handles a small private file.
- Temporary calculations need no lasting records.
Quick check
Takeaways
- A database stores data safely and finds it fast.
- Persistence means surviving restarts.
- Most features combine create, read, update, and delete.