You sell software to other businesses: a booking system for salons, an ordering portal for wholesalers, a tool for property managers. Every customer logs into the same system, and salon A must never see salon B's appointments, clients or invoices. Not once. One leak like that, and you lose more than one customer.
Developers call each of your customers a tenant, and software like this multi-tenant. How it keeps tenants apart is decided early in the build and is hard to change later. There are three ways. The cheaper and simpler the way, the easier it is to make a mistake.
Shared tables: every row labelled
All customers' data sits in the same tables, and every record carries a label saying whose it is. Every time the software reads data, it filters by that label.
You get the cheapest setup: one database to run, back up and update, and reports across all customers are easy.
Watch out: one forgotten filter, in one place, shows customer A's data to customer B. That risk never goes away. It lives in the code for as long as the product does.
A very busy customer can also slow everyone else down if the database isn't tuned for it. And "delete everything you have about us" means a search through shared tables, not one step.
Best fit: software for small businesses, data that isn't medical or financial, and a developer who filters every single query.
A schema each: separate rooms in one building
One database, but every customer gets their own set of tables, called a schema. A query aimed at the wrong customer doesn't quietly return their data. It fails with a visible error.
Mixing data by accident becomes hard. Returning or deleting one customer's data is simple, and big customers can take updates on their own schedule.
The price: the sets of tables grow with every customer, and past a few hundred customers the tools start to struggle. Reports across customers need extra work, and you now run a routine for each customer: create, update, archive.
Best fit: fewer, larger customers, more sensitive data, and customers who sometimes ask for their data back.
A database each: a separate building
Every customer gets their own database, sometimes their own server. Only running a separate copy of the software for each customer separates them more. Backup, restore and deletion work per customer, and a heavy customer can't slow anyone else.
The price: running costs grow with every customer, because backups, monitoring and capacity planning all multiply. The software has to hold a connection to each database, which gets hard from around 50 active customers. Reports across customers need a separate data warehouse.
Best fit: regulated industries like healthcare and finance, or a product where one customer handles more data than all the others together.
What I start with
For a new SaaS sold to small and mid-sized businesses, I start with shared tables. The savings are real, and you can move to a stronger model when your customers need it. The way forward exists: shared tables, then a schema each, then a database each. The way back is much harder, so don't pay up front for separation you don't need yet.
Rule: shared tables are only safe if no query depends on someone remembering the filter. I make the filter automatic, and a query without it fails.
For your developer
- Wrap the models so the tenant filter comes from the request automatically. Raw queries are the exception and carry a comment.
- Back it up with query middleware, so a handwritten query that forgets the tenant fails loudly instead of returning every tenant's rows.
- Neither is perfect, but together they shrink the risk from every query in the codebase to the places that bypass the wrapper on purpose.
// Mongoose: a find without a tenant throws instead of reading everyone's data.
schema.pre(/^find/, function () {
if (!this.getFilter().tenantId) throw new Error("Query without tenantId");
});Not sure how your product keeps customers apart? Ask whoever built it which of the three it uses, or book a call.