Multi-Tenant SaaS: Shared Schema, Schema per Tenant or Database per Tenant
There are three common ways to isolate tenants in a SaaS product: a shared schema with a tenant column, a schema per tenant, and a database per tenant. Each trades isolation strength against cost and operational effort.
What isolation has to guarantee
In a multi-tenant SaaS product, many customers, called tenants, share the same application. Isolation is the promise that one tenant can never read or change another tenant's data, and cannot degrade their service. The choice of isolation model is one of the earliest and hardest to reverse decisions in the product, so it is worth understanding the trade-offs before the first table is created.
Model 1: shared schema with a tenant column
All tenants share the same database and tables, and every row carries a tenant identifier. Queries are filtered by that identifier.
Strengths
- Lowest cost per tenant and the simplest infrastructure
- Schema changes and migrations run once
- Easy cross-tenant reporting for your own operations
- Scales to a very large number of small tenants
Risks
Isolation depends entirely on every query being filtered correctly. One missing condition in one code path can expose another tenant's data. A noisy tenant can also slow the shared database for everyone. You can reduce these risks with mechanisms that enforce the filter automatically, such as global query filters in the data layer or row-level security in the database, but the discipline has to be built in from the start.
Model 2: schema per tenant
Each tenant gets its own schema inside one database, with the same table structure. The application selects the schema for each request.
Strengths
- Stronger separation, because a forgotten filter cannot cross a schema boundary
- Easier to export, restore or delete a single tenant's data
- Per-tenant customisation is possible
Risks
Migrations must run across every schema, which takes longer and can fail partway. Very large numbers of schemas strain the database catalogue and tooling. Cross-tenant analytics needs extra work.
Model 3: database per tenant
Each tenant has a separate database, or even a separate deployment. This offers the strongest isolation and the clearest answer to a security questionnaire.
Strengths
- Strongest data separation and independent backup, restore and encryption keys per tenant
- Resource usage is isolated, so one tenant cannot slow another
- Meets strict regulatory or contractual demands, and tenants can be placed in specific regions
Risks
Highest cost and operational load. Provisioning, migrations, monitoring and connection management all multiply with the number of tenants. This model suits fewer, larger customers rather than thousands of small ones.
| Shared schema | Schema per tenant | Database per tenant | |
|---|---|---|---|
| Isolation strength | Logical, depends on code and policies | Stronger, structural | Strongest |
| Cost per tenant | Lowest | Medium | Highest |
| Migrations | Run once | Run per schema | Run per database |
| Noisy neighbour risk | Highest | Medium | Lowest |
| Best for | Many small tenants | Mid-sized tenants needing separation | Few large or regulated tenants |
Defence in depth, whichever model you pick
No single mechanism should carry the whole burden. Combine several layers.
- Resolve the tenant once, from the authenticated identity, and carry it through the request rather than trusting a value sent by the client
- Apply tenant scoping automatically in the data layer so developers cannot forget it
- Add database-level controls such as row-level security where available
- Encrypt sensitive fields, and consider per-tenant keys for the most sensitive data
- Write an audit trail of who accessed or changed what
- Test isolation explicitly: automated tests that try to read another tenant's records and must fail
Choosing in practice
Ask four questions. How many tenants do you expect, and how large is each? What do your customers or regulators require in writing about data separation? How different will tenant needs be, such as custom fields or regions? And how much operational effort can your team carry?
For many early products, a shared schema with strong automatic scoping, row-level controls and an audit trail is the sensible start, because it keeps costs and complexity low while the product finds its market. Design the data access layer so the tenant boundary is explicit; that keeps a later move to schema or database separation for large customers possible without a rewrite. A hybrid is also common, with most tenants on shared infrastructure and a few enterprise tenants on dedicated databases.
We apply these ideas in products we run, such as CPAFriend, where data separation between clients is central. Our SaaS development service includes the tenancy design, billing and entitlements, and the cloud and DevOps work to run it. To discuss your own model, use the contact page.
Can we change the isolation model later?
Yes, but it is a migration project. It is far easier if the tenant boundary is explicit in your code from the start.
Is a shared schema secure enough?
It can be, with automatic scoping, database-level controls, encryption and tests. It depends more on the quality of the controls than on the model name.