Part 2 of 6 · 2 min read
The problem: everything kept in plain files
What goes wrong once more than one program shares the same stored data.
Think of a shop that keeps its records on paper, in three separate notebooks: one for stock, one for customer orders, and one for money owed. Each clerk writes in whichever notebook their job touches. Nobody reads all three at once.
In plain words: a program that stores its data in plain files behaves the same way. One program writes customer names into a file; another program, written later by someone else, writes orders into a different file, often repeating the customer's name and address inside it. Nothing connects the two files except the people who wrote the programs remembering to keep them in step. As more programs are added, more files are added, and each new file repeats data that already exists somewhere else.
A worked example. A small bookstore keeps two files: customers.txt, with 400 customer records, and orders.txt, with 1,200 order records. Each order record repeats the customer's full name and delivery address, because the program that writes orders was never connected to the program that writes customers. One customer moves house. The address needs updating in up to 3 order records already on file, plus the customer file itself — 4 places, in 2 files, by hand or by a script someone has to remember to run. Miss one, and the bookstore now has two different addresses for the same person, with no way to tell which is current.
The key lines. There is no code yet — this part is about the files themselves, not a program. A later part shows the SQL that replaces them.
Data redundancy, data inconsistency
Data redundancy is the same fact stored in more than one place. Data inconsistency is what happens when those copies stop agreeing, because one was updated and the other was not.
Example: the bookstore's customer address, stored once in customers.txt and copied into every one of that customer's order records, is redundant; if only the customer file gets updated, the order records become inconsistent with it.
Redundancy is not only wasted space. It is the direct cause of inconsistency: every extra copy of a fact is one more place an update can be forgotten.