A SaaS database can keep every customer in shared tables, assign each customer a separate schema, or provision a separate database. The best choice depends on isolation requirements, tenant count, operating cost, and how often individual customers must be backed up or moved.
Last updated: September 8, 2026.
CREATE TABLE projects (
tenant_id BIGINT NOT NULL,
project_id BIGINT NOT NULL,
name VARCHAR(200) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, project_id),
INDEX (tenant_id, created_at)
);In the shared-table model, tenant_id is part of every tenant-owned row and normally part of important keys and indexes. Application queries must enforce tenant isolation on every read and write.
Compare the three models
| Model | Strength | Cost |
|---|---|---|
| Shared tables | Simple operation at high tenant counts | Lowest per tenant |
| Schema per tenant | More logical separation | More migration work |
| Database per tenant | Strong isolation and individual restore | Highest operational overhead |
Shared tables are often appropriate when tenants have similar requirements and the application can enforce tenant-aware access consistently. Separate databases are useful for regulated customers, regional placement, customer-specific restore, or unusually large tenants. A hybrid design can place most customers in shared databases while assigning selected customers to dedicated databases.
Make the decision reversible
Store tenant placement in a central catalog rather than embedding connection details throughout the application. A request resolves the tenant, reads its placement record, and then selects the correct database or shard. This also helps automated onboarding and allows a tenant to move later.
Whichever model you choose, establish one automated schema migration process. Do not maintain hand-edited schemas for individual customers. Document the chosen model and its isolation boundary. Microsoft’s multitenant data guidance describes the same tradeoffs and warns against creating separate tables for each tenant.
Building a database-backed SaaS application?
PHPRunner can generate the application layer for MySQL, SQL Server, PostgreSQL, and other databases. Explore PHPRunner.