Lesson 1 / 25

Why Databases Instead of Files

Explain the problems a DBMS solves compared with plain files.

From files to a database management system

Early applications stored data in their own files: a CSV for customers, another for orders. As systems grew, this caused well-known problems. Redundancy and inconsistency: the same customer address is copied into several files and updated in only one. Difficult access: every new question needs a new program. Integrity problems: rules such as "balance must not be negative" are buried in application code. Atomicity problems: a crash halfway through a transfer leaves money debited but not credited. Concurrency anomalies: two clerks updating the same record overwrite each other. Security: it is hard to give users access to some data but not all. A database management system (DBMS) is software that stores data centrally and provides a query language, integrity constraints, transactions with crash recovery, concurrency control, access control and efficient storage and indexing. Popular relational DBMSs include PostgreSQL, MySQL, Oracle Database, SQL Server and SQLite.

Files versus a DBMS

Separate programs with separate files on one side; many applications sharing one managed database on the other.

Left: three program boxes each attached to its own file icon with duplicated content. Right: three program boxes all connected to a single central database cylinder with a shield.
Figure 1.1 — File-based storage compared with a shared DBMS.

The same fact stored twice

Updating one copy and not the other leaves the data inconsistent.

customers.csv
  id,name,city
  42,Asha Rao,Pune

orders.csv
  order_id,customer_id,customer_city,total
  1001,42,Pune,1499

Asha moves to Bengaluru; the program that edits customers.csv updates the city,
but orders.csv still says Pune -> two different answers to "where does Asha live?"
A DBMS stores the city once and lets every query join to it.

Exam favourite

"List the disadvantages of file-processing systems" is a classic DBMS exam question. Remember them as redundancy, access difficulty, isolation of data, integrity, atomicity, concurrency and security problems.

Quick check: Which problem of file-based systems does a DBMS address with transactions?

  • Atomicity: a crash halfway through an update leaving data partially changed
  • Choosing file names
  • Displaying data in colour
  • Compressing images
Answer

Atomicity: a crash halfway through an update leaving data partially changed — Transactions make multi-step updates all-or-nothing, even across crashes.