A developer-friendly guide with theory, standards, and a practical multi‑store example
by a backend engineer who learned to think in tenants
Designing a database for a SaaS application is very different from building for a single user or a single business. In a normal app, you manage one business. In SaaS, you manage many independent businesses inside one system. That changes everything.
In this article, I’ll walk you through:
- What SaaS database theory really means
- The standards you must follow
- Industry practices that actually work
- A real example: a multi‑store eCommerce platform
- A backend developer’s practical perspective
Let’s build this step by step — the way I wish someone had shown me.
1️⃣ First: What makes SaaS database design different?
SaaS (Software as a Service) means: one platform, multiple independent customers (tenants), shared infrastructure.
Think about platforms like Shopify. One application. Thousands of stores. Each store sees only its own data. The biggest rule in SaaS database design is: No tenant’s data should ever mix with another tenant’s data. That’s the foundation.
2️⃣ Core SaaS database theory
When you design for SaaS, you focus on three things:
- Multi‑tenancy – multiple organisations use the same system.
- Data isolation – each tenant’s data must be logically separated.
- Scalability – the system must handle growth without a complete redesign.
Multi‑tenancy models (the theory)
There are three main ways to separate tenant data:
- A. Separate database per tenant – each store gets its own database. Very secure, but a nightmare to manage at scale.
- B. Separate schema per tenant – same database, different schemas. Medium complexity.
- C. Shared database + tenant ID (most common) ✅ – All tenants share the same tables, and every row has an
org_id(tenant identifier). This is what most of us use, and it’s what we’ll focus on.
3️⃣ Industry standards you should follow
After building a few SaaS backends, I’ve learned these standards are non‑negotiable:
- ✅ Use Third Normal Form (3NF). No duplicate data, no partial dependencies, clean relationships. SaaS systems grow large, and redundancy becomes dangerous and expensive.
- ✅ Always include a tenant identifier. Every business‑related table must have
org_id(ortenant_id,store_id). This is your isolation key. - ✅ Enforce integrity at the database level. Use foreign keys, unique constraints, indexes. Never depend only on application validation.
- ✅ Optimise for
org_idfiltering. Almost every query will beSELECT ... WHERE org_id = ?. Index that column and design queries around it.
4️⃣ Developer perspective: how to think before writing tables
Before I write a single CREATE TABLE statement, I ask myself:
- Who is my tenant? (A store? A company? A workspace?)
- What belongs to a tenant?
- What data is global (like country lists or plan types)?
- What should happen if a tenant is deleted?
- How will I prevent data leakage?
This mindset separates beginners from SaaS engineers.
5️⃣ Practical example: a multi‑store SaaS platform
Let’s design something real. Imagine a platform that hosts multiple online stores. Each store has its own users, products, and customers — but no ordering system, to keep things simple.
Step 1: Organizations table (the tenants)
This is the root of everything. One row = one store using the platform.
organizations
--------------
id (PK)
name
email
phone
status
created_at
updated_at
Step 2: Users table
Each store can have multiple users (owner, staff).
users
------
id (PK)
org_id (FK → organizations.id)
name
email
password
role
status
created_at
org_id links the user to a specific store. Use UNIQUE (org_id, email) because two different stores can both have [email protected].
Step 3: Products table
products
---------
id (PK)
org_id (FK)
name
description
price
stock
status
created_at
Rules: UNIQUE (org_id, name) (a store shouldn’t have two products with the same name), and index org_id. Now Store A (org_id=1) and Store B (org_id=2) have completely separate product lists, even though they live in the same table.
Step 4: Customers table
customers
-----------
id (PK)
org_id (FK)
name
email
phone
address
status
created_at
Again, each store manages its own customers.
6️⃣ How data isolation actually works (the code part)
When a user logs in, your backend stores their org_id in the session or token. Then every query becomes:
SELECT * FROM products WHERE org_id = 2; -- only products for the current store
Never trust the frontend to send the correct org_id. Always extract it from the authenticated user's token. That’s how isolation is enforced.
7️⃣ Why this design is clean (a developer’s view)
This structure gives you:
- ✔ Clear tenant separation
- ✔ Easy future expansion
- ✔ Safe data boundaries
- ✔ Clean relationships
- ✔ A scalable foundation
Later you can add orders, subscriptions, billing, audit logs, or analytics — without breaking the core design.
8️⃣ Performance considerations
In SaaS, performance matters from day one. Some habits I always follow:
- Index every
org_idcolumn. - Use composite unique keys like
(org_id, email)or(org_id, name). - Use soft deletes (
deleted_at) instead of hard deletes. - Avoid unnecessary joins in hot queries.
As the system grows, you might intentionally denormalise for speed — but only when you have a real need.
9️⃣ Common mistakes in SaaS database design
I’ve made some of these myself, so I keep a mental checklist:
- ❌ Forgetting to filter by
org_idin a query (hello, data leak). - ❌ Storing organisation details (like name) in every table — just use
org_idand join when needed. - ❌ Not using foreign keys (they keep your data sane).
- ❌ Making email globally unique (two tenants can’t both have
info@? yes they can). - ❌ Over‑normalising too early (sometimes a little redundancy is okay for speed).
Start clean. Optimise later.
🔟 Final architecture overview
Your SaaS structure becomes a simple tree:
Organization
├── Users
├── Products
└── Customers
Every business table contains org_id. That’s the core of SaaS database architecture.
Final thought (developer mindset)
Designing a SaaS database isn’t just about tables and columns. It’s about thinking in tenants. Thinking in isolation. Thinking in scale. Thinking in long‑term maintainability.
If you master this foundation, you can build CRM systems, multi‑vendor marketplaces, school management platforms, enterprise dashboards, or inventory tools. SaaS architecture is not complex — it just requires disciplined structure and clear thinking.
And once you truly understand tenant isolation, you stop building apps. You start building platforms. 🚀
Written by a backend engineer who learned these lessons the hands‑on way.




