Why Databases Exist
Learn the real-world problems databases solve and why applications need them.
Databases exist because important information is hard to manage safely with simple files, memory, or human discipline alone.
At a tiny scale, almost anything works. You can write names in a notebook, save a list in a text file, or keep a budget in a spreadsheet.
But as soon as more people, more rules, more history, and more questions appear, information becomes harder to keep correct.
Databases were invented to help with that.
The simple version
A database helps an application:
- remember information after the program closes
- find the right facts quickly
- keep related facts consistent
- handle overlapping requests safely
- recover when something goes wrong
Without a database, every application would have to reinvent these abilities.
Problem 1: memory disappears
Programs use memory while they run.
Memory is fast, but temporary.
If an application stores your shopping cart only in memory, the cart disappears when the app stops.
Databases store information durably, which means the information is meant to survive after the program exits.
With SQLite, durable data usually lives in a database file on disk. Your app can close, open later, and read the saved facts again.
Problem 2: files become messy
Files are useful. SQLite itself stores a database in a file under the hood.
But if each application invents its own pile of files, it must also invent:
- how to search them
- how to update one fact without breaking another
- how to stop two writes from colliding
- how to recover after a crash
- how to tell whether the data is valid
A database gives you a tested system for those jobs.
Problem 3: many actions can touch the same data
Imagine two employees editing the last available seat on a tour bus.
If both people see "1 seat left" and both click "book," the application must not sell the same seat twice.
This is called a concurrency problem: more than one thing is happening at the same time.
SQLite is especially good for apps with many readers and simpler write patterns. It can protect writes so the database file is not corrupted, but it is not designed for huge numbers of users writing at the exact same moment like a large client-server database might handle.
Problem 4: facts must stay correct together
Some changes involve more than one fact.
Example: when a customer places an order, the application may need to:
- create the order
- add order items
- reduce inventory
- record payment status
If only half of those changes happen, the data becomes confusing or wrong.
Databases support transactions, which let a group of changes be treated as one unit.
Why is "sell the last seat twice" a database problem?
It is about choosing a font
Two overlapping actions can conflict unless the data is protected
It only happens when nobody uses computers
It proves files cannot store text
Problem 5: questions get more complicated
Simple storage is not enough. Applications need to ask questions.
Examples:
- Which customers ordered this month?
- Which products are almost out of stock?
- What was our total revenue last week?
- Which students have missing assignments?
A database gives you a query language so you can ask for exactly the data you need.
Problem 6: data grows
What works for 20 rows may not work for 20 million.
As data grows, applications need better ways to:
- organize it
- search it
- avoid reading everything
- keep repeated operations predictable
Databases are built around these needs. They can use structures such as indexes to find information without scanning every row every time.
Problem 7: things fail
Computers crash. Power goes out. Bugs happen.
A database cannot prevent every failure, but it can reduce how often failures corrupt your data.
Durability means that once the database says a change is saved, it should not vanish just because the program ended.
Why not just use files?
Sometimes files are exactly right.
A profile photo, a PDF receipt, a configuration file, or a short note may belong in a regular file.
The question is not "files or databases forever?"
The better question is:
Does this information need structure, searching, rules, safe updates, or long-term trust?
If yes, a database is often the better tool.
The main idea
Databases exist because software needs a dependable way to remember, search, change, and protect important information.
They are not just storage. They are systems for keeping data useful as people and applications depend on it.
Check your understanding
What does durability mean?
The database is always colorful
Saved data should survive after the program stops or something goes wrong
Every query returns every row
Users never make mistakes
What is a transaction?
A picture stored in a folder
A random spreadsheet color
A group of database changes treated as one unit
A username only
Why do databases help when data grows?
They make every question slower on purpose
They remove the need to organize information
They provide structures and query tools for finding information efficiently
They only work with tiny lists
What is one honest limitation of SQLite compared with large client-server databases?
It cannot store data in tables
It cannot read saved data after an app closes
It is not the best fit for heavy multi-user write concurrency
It cannot run SQL