Databases, Clearly Explained

Database vs. DBMS: Who Does What

9 min

Chapter 1 — “Map of the Archive”

The Kotomarket is no longer a signal from a dead sector — it now sits in the quarantine wing of Vault-9, with the same signature beneath the final line of its : “K.” That morning, a new entry flashes across your holopanel: “Clearance: archive inventory. Issued by: S.Q.L. module.” The vault door slides aside; beyond it, server racks hum steadily in amber light.

QUERY: Before you read someone else's memory, understand how it's organized. Start with the basics: which part is the storage, and which part is the keeper?

A cadet at the entrance to the vault: a holographic guardian acting as the DBMS stands between the cadet and the memory racks
The archive stores the memory, but only the keeper answers questions: a query goes to the DBMS, and only the DBMS accesses the data.

Database and DBMS

A database is an organized data store. The Kotomarket contains customers, products, orders, and events. They aren't scattered across separate files; they're arranged in a clear structure, which is why we can still read them a hundred and sixty years later.

The storage itself can't answer questions. You need software that can create tables, record new orders, read data, and make sure relationships stay valid. That's a (database management system). Examples include PostgreSQL, MySQL, and ClickHouse. Our snapshot is a PostgreSQL database, and it still speaks the same SQL it used while the store was running.

You write an SQL query → send it to the DBMS → the DBMS retrieves the data you need and returns the result. Excel is fine for a personal spreadsheet, but not for a store where thousands of users are browsing products, placing orders, and recording events at the same time.

clientDBMSparserplannerexecutordata filesSQL queryresultdatathe client talks to the DBMS, not the files directly
Every path to the data goes through the DBMS: it receives SQL, executes it, and protects the database's integrity.

What a DBMS can do that “just files” can't

A store might seem able to get by without a and simply write orders to CSV or Excel files. That can work at the scale of a personal notebook, until you run into the problems DBMSs were designed to solve.

  • Concurrent access. In the live Kotomarket, customers placed orders at the same time. Two processes writing to the same file can overwrite each other's changes; a DBMS applies changes as and coordinates parallel operations. PostgreSQL does this through : readers don't block writers, and writers don't block readers.
  • Crash recovery. If the power cuts out halfway through a write, a file may be corrupted, and you may not know how much of the order was saved. A DBMS first records the change in a log (in PostgreSQL, , or write-ahead log) and replays it after a crash: the order is either written completely or not written at all.
  • Access permissions. A file is either accessible as a whole or not at all. A DBMS can grant permissions as narrowly as a single table:
-- Give the analyst read-only access to orders, with no permission to change them
GRANT SELECT ON orders TO analyst;
  • Integrity. A DBMS won't accept an order with text where a price should be, or a reference to a customer who doesn't exist: column types and are checked on every write. A file doesn't care what you put in it.
  • Declarative queries. “Show me orders over 5000” takes one line of SQL. With a file, someone has to write a program to do the same job and make sure it works correctly.

A acts as the intermediary between you and the data: it accepts SQL queries, executes them, and keeps the database from falling into chaos. In this course, we use PostgreSQL — it's commonly required for analytics and backend roles. You've met the keeper. Before you open the inventory for our , QUERY leads you to the next section: a registry of other archives from old Earth, where you'll see why ours survived intact.

Interview question

Interview question: what's the difference between a database and a ? Why shouldn't an application simply store its data in files?

Strong answer: a database is organized data, while a DBMS is the software that manages it (PostgreSQL, MySQL, ClickHouse). Files don't provide concurrent access (parallel writes can overwrite each other), crash recovery (a DBMS keeps a log and replays unfinished changes), granular permissions, or integrity checks. A DBMS also handles declarative SQL queries; with a file, you'd have to read and process the data with your own code.

Check yourself
Who does what: the database or the DBMS?