Moving from Single Tables to Real-World Database Design
Up until now, we’ve spent a good amount of time writing basic SQL. But if we’re being honest, the SQL we’ve written so far doesn’t really reflect how things work in the real
MSMuhammad SufiyanSoftware Engineer · 4d ago
Backend Engineering HubT-
Up until now, we’ve spent a good amount of time writing basic SQL.
But if we’re being honest, the SQL we’ve written so far doesn’t really reflect how things work in the real world.
So far:
We worked with a cities table in one database
We worked with a phones table in another database
Each database had only one table
This is great for learning SQL basics, but it’s not how real applications work.
Reality Check: Real Apps Don’t Use One Table
In real-world applications:
Databases almost never have just one table
Data is spread across multiple tables
Tables are connected to each other through relationships
Yes, it’s possible to have a single-table database, but you’ll almost never see that in professional systems.
So if we want to learn SQL properly, we need to move closer to reality.
What’s Next?
From this point onward, we’re going to work with:
multiple tables
relationships between tables
more realistic database designs
To do this, we’ll design a database for a photo-sharing application.
This will be a bit more challenging — but that’s a good thing.
Because this is the kind of work you’ll actually do when working with PostgreSQL in real projects.
Example: A Photo Sharing Application
Let’s imagine we’re building something like Instagram.
For a basic photo-sharing app, we can already identify a few core features:
Users can sign up
Users can upload photos
Users can comment on photos
Users can like photos
From this alone, we can guess that our database will need at least these tables:
users
photos
comments
likes
How Do We Decide What Tables to Create?
A very important question is:
How do we know which tables we need?
Here are a few practical tips.
1. Most Apps Share Common Features
Many applications share similar features, such as:
user authentication
comments
likes or upvotes
followers
Because these features are common, other developers have already solved these problems.
So your first resource should always be:
👉 Google
For example:
“SQL schema for like system”
“database design for comments”
“SQL upvote system”
You’ll find tons of real examples and discussions.
2. Look at App Screens and UI Mockups
If you’re building something new, look at:
app mockups
UI screens
user flows
Ask yourself:
What resources exist here?
What things are being created, owned, or interacted with?
Each major resource usually becomes a table.
Breaking Down Instagram as an Example
Let’s take Instagram as an example.
User Profile Screen
From a profile page, we can see:
A username
A bio
Followers and following
A list of photos
This tells us:
There is a users table
A user owns many photos
Users can follow other users (relationships between users)
Photo / Post Screen
From a single photo screen, we can see:
Comments
Likes
Each comment belongs to a user
Each comment belongs to a photo
Likes belong to users and photos
This tells us:
There is a comments table
There is a likes table
Comments and likes are related to both users and photos
Identifying Relationships
From just these screens, we can already identify relationships:
A user creates many photos
A user creates many comments
A user creates many likes
A photo has many comments
A photo has many likes
This is exactly how real database design starts:
identify resources
identify ownership
identify relationships
Key Takeaways
Single-table databases are not realistic
Real apps use multiple related tables
Tables represent real-world resources
Relationships are just as important as data itself
UI screens are a great way to understand database needs
HIRINGMINE CAREER SIGNAL
This writing is proof of expertise.
Explore the author’s verified skills, projects and availability—or start a professional conversation.