Before PostgreSQL: Why Do Databases Exist?
Before learning PostgreSQL, let’s start with a simple question:
Why do we need databases at all?
When we use an app, data is created all the time.
user signs up
product added to cart
payment completed
message sentAll of this data needs to live somewhere.
At first, the easiest answer is: save it in a file.
Starting With a File
Imagine we store users in a file:
1, Alice, alice@example.com
2, Bob, bob@example.com
3, Carol, carol@example.comIf we want Bob, we can read the file and find this line:
2, Bob, bob@example.comFor a tiny app, this works.
Application
|
v
users.txtBut once the app grows, problems appear.
Why Files Are Not Enough
What happens when we have millions of users?
What happens when two people update the file at the same time?
What happens if the computer crashes while writing data?
What happens if we need to find a user quickly by email?
What happens if users have orders, payments, and addresses?
A file can store data.
A database manages data.
File
|
+-- stores dataDatabase
|
+-- stores data
+-- finds data quickly
+-- updates data safely
+-- handles many users
+-- recovers after crashesThat is the difference.
What a Database Does
A database helps answer important questions:
Where should data live?
How should data be organized?
How do we find data quickly?
How do we update data safely?
What happens if many users use it at once?
What happens if the system crashes?So a database is not just a place to put data.
It is a system for keeping data useful, safe, and available.
Example: Asking for Data
Suppose we ask:
SELECT name
FROM users
WHERE id = 2;This query means:
Find the user whose id is 2
and return the nameThe result might be:
BobFrom the outside, it looks simple.
SQL Query
|
v
Database
|
v
ResultBut inside the database, a lot happens.
Get Deepa Yadav’s stories in your inbox
Join Medium for free to get updates from this writer.
The database has to understand the query, decide how to find the data, read the data, and return the result.
Where PostgreSQL Comes In
PostgreSQL is a database system.
It supports SQL, stores data, handles transactions, uses indexes, manages many users, and can recover after crashes.
PostgreSQL
|
+-- SQL
+-- tables
+-- indexes
+-- transactions
+-- concurrency
+-- recoveryWhen we write a query like this:
SELECT name
FROM users
WHERE id = 2;PostgreSQL turns it into internal work.
A simplified version looks like this:
SQL
|
v
Parser
|
v
Planner
|
v
Executor
|
v
Storage
|
v
ResultWe do not need to understand all of these parts yet.
For now, the main idea is:
PostgreSQL takes a SQL query and turns it into real work on stored data.
The Big Idea
A small app might survive with a file.
A growing app needs something stronger.
Small app
-> fileGrowing app
-> databaseDatabases help with:
speed
safety
organization
many users
crash recoveryPostgreSQL is one of the best databases to learn because it is powerful, widely used, and open source.
That means we can study not only how to use it, but also how it works inside.
What Comes Next
In this series, I’ll explore PostgreSQL from the inside out.
We’ll start simple and slowly build the full picture.
Next, we’ll ask:
What happens when PostgreSQL starts for the first time?
And later, we’ll follow one query through the system:
SELECT name
FROM users
WHERE id = 2;Step by step, we’ll move from SQL to the internals behind it.
Further Reading
If you want to build a stronger foundation before going deeper into PostgreSQL, these are good places to start:
- PostgreSQL Official Documentation
The best primary source for learning how PostgreSQL behaves. Start with SQL, tables, indexes, transactions, and server basics. - PostgreSQL Tutorial
A beginner-friendly place to learn PostgreSQL and basic relational database concepts. - Database System Concepts
A classic textbook for understanding why databases are designed the way they are. - Designing Data-Intensive Applications
A great book for learning how modern data systems handle storage, reliability, consistency, and scale. - PostgreSQL Internals Overview
Useful when you are ready to move from using PostgreSQL to understanding how PostgreSQL works inside. - Use The Index, Luke!
A beginner-friendly resource for understanding indexes and SQL performance.



