liveBook · Manning

Schema-level multitenancy

As explained in Just Use Postgres!

Schema-level multitenancy gives each tenant a dedicated schema containing its own tables within one logical database.

Schema-level multitenancy gives each tenant a dedicated schema containing its own tables, while all tenant schemas remain within one logical PostgreSQL database. This isolates merchant data without creating a separate database for every tenant. section 2.1.1

Multitenancy can isolate tenant data at several database boundaries:

  • Table-level multitenancy stores all tenants in shared tables and distinguishes rows with a tenant identifier. section 2.1.1
  • Schema-level multitenancy gives every tenant separate tables inside its own schema. section 2.1.1
  • Database-level multitenancy gives every tenant a separate database, allowing tenant databases to be distributed across PostgreSQL servers. section 2.1.1

Merchant isolation

A brewery and a coffee chain can use the same platform without sharing business data. The demonstrated implementation chooses database-level isolation instead: separate databases named coffee_chain and brewery are created and inspected with psql. section 2.1.1

How Just Use Postgres! covers it

How deep it goes
Defines dedicated tenant schemas and contrasts isolation levels, but stops short of schema creation or permission configuration.
Examples
Uses a brewery and coffee chain scenario, with separate PostgreSQL databases demonstrated as the selected alternative.
What you can do after
Evaluate schema-level isolation against table-level and database-level designs for merchant data.
How it connects
Connects multitenancy with tenants, tables, databases, roles, permissions, and data isolation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.