Table-level multitenancy stores multiple customers’ records in shared tables, then relies on tenant columns and application query predicates to keep rows separated. section 7.4
Treat the tenant boundary as an application responsibility:
- Tag rows with identifiers such as userId, teamId, or organizationId. section 7.4
- Apply the correct tenant predicate to every query; a missing condition can expose another customer’s rows. section 7.4
- Track nested ownership carefully: newer organization membership can require checking more than one ancestor identifier. section 7.4
Table 7.4 Common database designs for multi-tenancy
|
Model
|
What
isolates tenants
|
What it
buys
|
What it
costs
|
|
Single-tenant
|
One deploy
per customer
|
Total
isolation, trivial reasoning
|
No economy
of scale; Cal.com's self-host story, not its cloud
|
|
Shared
table, tenantId column
|
A WHERE userId/teamId = ?
on every query
|
One
database, one schema, cheapest to operate, what Cal.com runs
|
One missing
WHERE is a cross-tenant
leak; the DB won't stop you
|
|
Schema-per-customer
|
A Postgres
schema namespace per tenant
|
Isolation
without a fleet of databases; per-tenant backup
|
Migrations
fan out across N schemas; connection-pool pressure
|
|
Database-per-customer
|
A whole
database per tenant
|
Strong
isolation, per-tenant scaling and residency
|
Heaviest
ops; migrations and monitoring multiply by tenant count
|
Compare shared-table tenancy with single-tenant, schema-per-customer, and database-per-customer isolation models. section 7.4
Figure 7.6 In a shared table, the application enforces tenant isolation by adding WHERE teamId = ? to every query. Forgetting this clause leaks one tenant's private data to another.

Visualize the required tenant predicate and the failure mode caused by omitting it. section 7.4

