Module 15 · Data modelling · Lesson 1 of 5
What a DBMS does
Why programs keep data in a database management system instead of files: the problems a DBMS solves, its layered architecture from query to disk, data independence, and the vocabulary (schema, instance, DDL, DML) this whole stage uses.
Why it matters
Every application that outlives a single run needs to keep data somewhere. Writing it to files works until two users edit at once, the machine crashes halfway through a save, someone needs a report the code was not written for, or the data no longer fits in memory. A database management system exists to solve exactly those problems once, for everyone. Knowing what it does for you, and how it is built, is the foundation for every lesson in this stage and for most of the database questions in interviews.
The idea
A database is an organised collection of data. A database management system (DBMS) is the software that stores it, answers questions about it, keeps it consistent, and protects it from concurrent users and crashes. Programs never touch the data files directly; they send requests (usually SQL) and the DBMS does the work.
What goes wrong with plain files
| Problem with files | What the DBMS provides |
|---|---|
| Data duplicated across files drifts apart | One shared, integrated store with constraints |
| Every new question needs a new program | A declarative query language: say what you want, not how to find it |
| Two users editing at once overwrite each other | Concurrency control: transactions that behave as if run alone |
| A crash mid-save leaves half-written data | Atomicity and recovery from a log |
| Anyone with file access sees everything | Users, roles and permissions per table and column |
| Changing the file format breaks every program | Data independence: storage can change without changing queries |
| Searching means reading everything | Indexes and a query optimizer |
Inside a DBMS
Schema, instance and data independence
The schema is the structure: tables, columns, types, constraints. It changes rarely. The instance is the data in the database at one moment, which changes constantly. Databases describe data at three levels (the three-schema architecture): the external level (views tailored to each user or application), the conceptual level (the logical structure of all data) and the internal level (how it is physically stored). This separation gives data independence: physical independence means you can add an index, change file layout or move to faster disks without changing any query; logical independence means you can add a column or split a table and keep old applications working through views. It is the single most important idea a DBMS provides.
The languages
| Language | Purpose | Examples |
|---|---|---|
| DDL (data definition) | Define and change the schema | CREATE TABLE, ALTER TABLE, DROP INDEX |
| DML (data manipulation) | Read and change the data | SELECT, INSERT, UPDATE, DELETE |
| DCL (data control) | Grant and revoke permissions | GRANT, REVOKE |
| TCL (transaction control) | Group changes into units | BEGIN, COMMIT, ROLLBACK, SAVEPOINT |
SQL contains all four. It is declarative: a query describes the result, and the DBMS's optimizer decides the steps, which is why the same query can get faster after someone adds an index without anyone rewriting it.
Who touches the database
End users through applications; application developers writing queries; and database administrators who manage schema, permissions, backups, performance and recovery. In most companies today the DBA role is shared between platform teams and managed cloud services, but the responsibilities have not gone away.
Trade-offs
A DBMS buys correctness under concurrency and crashes, flexible querying and independence from physical layout, at the cost of overhead for each operation, operational work (backups, upgrades, tuning) and a schema that must be designed and evolved. For a configuration file or a cache, plain files or a key-value store are simpler; for shared business data that must stay correct, a DBMS is the default.
In an interview
The classic opener "why use a DBMS instead of files?" wants the list from the comparison table in your own words: integration without redundancy, declarative queries, concurrency control, crash recovery, security and data independence. Follow with one concrete failure: "two clerks updating the same seat booking file would both sell the last seat; a DBMS serialises those transactions."
Check yourself
A team adds an index to a large table and every report gets faster, yet no query text changed. Which DBMS property made that possible?