Skip to content
BENIBIX Learn

Multi-Tenancy

Development🏗️ ArchitectureArchitecture Styles

Also known as Multi-Tenant Architecture, Multitenancy, Multi-Tenant SaaS

One app that serves many customers. Each one's data is kept apart.

Think of it like

It is like a block of flats. Many families share one building, and each has its own locked door.

Example

Lucy's booking app serves 300 gyms from one database. Each table has a gym_id column, and each query checks it.

Why it matters

Sharing one app keeps costs low and updates simple. Done badly, one client can see the data of another.

Definition

Multi-tenancy means one copy of an app serves many customers and keeps their data apart. Each customer is called a tenant. All tenants share the same code and servers. Their data may share one database with a tenant ID on each row, or each may get its own database. Every query must filter by tenant, so no one sees the rest. Most apps sold as a service work this way.

Example code

sql
SELECT * FROM bookings
WHERE gym_id = 42 AND day = '2026-11-17';
Every query names the tenant, here gym 42, so it only sees its own rows.
Three gyms share one app and one table. The gym id keeps each one's rows apart.

Common mistake

Leaving out the tenant filter on one query. One missed line can show a customer the data of another. So check it in one place for all queries.

Key takeaways

  1. 1
    A shared app. One copy for all.
  2. 2
    Data kept apart. By row, schema or database.
  3. 3
    Filter everywhere. Every query checks the tenant.