System Design Academy

Saving…

Lesson 1 of 10 in Module 30 of 54 lessons complete

What Is a Database?

Module 3, lesson 1Concept10 min

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.
StoreSurvives restart?Many writers?Search?
Program memoryNoNeeds coordinationYou build the lookup
Plain fileYes, after saving safelyYou coordinate accessYou build the search
DatabaseWith durable settingsCoordinates supported writesBuilt-in query tools
  1. Ask

    Your app sends a query to read or change data.

  2. Check

    The database checks the request and finds the matching records.

  3. 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.

The database coordinates requests and saves lasting changes.

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.

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

Why not keep all user data in the web server's memory?
A user edits their profile. Which CRUD action is that?

Takeaways

  • A database stores data safely and finds it fast.
  • Persistence means surviving restarts.
  • Most features combine create, read, update, and delete.

Try the quick check above whenever you feel ready.

Previous: Single Points of Failure & Redundancy