A tenant is an independent customer or merchant whose data and operations remain isolated inside a shared multitenant SaaS application. A brewery and a coffee chain can use the same eCommerce platform without sharing business data. section 2.1.1
Postgres multitenancy commonly separates tenant data at three levels:
- Table level: store all tenants in shared tables and distinguish records with a tenant_id column. section 2.1.1
- Schema level: give each tenant dedicated tables within its own schema in one logical database. section 2.1.1
- Database level: give each tenant a dedicated database object, protected through roles and permissions. section 2.1.1
Separate merchant databases
Create one database for each merchant, then verify the instance contents: CREATE DATABASE coffee_chain; CREATE DATABASE brewery; SELECT datname FROM pg_database; The result lists both tenant databases alongside PostgreSQL’s default databases. Connecting with \c coffee_chain switches the session to the coffee-chain tenant.



