Insights / Data, Privacy & Security · · Updated · 14 min read

Tenant isolation explained: separate databases, schemas and row-level security

Compare tenant isolation patterns, PostgreSQL and SQL Server row-level security, and the access controls needed beyond the main database.

Tenant isolation is the answer to one plain question: can one customer's data ever show up for another customer? Not in theory, not "only if someone makes a mistake" — can it happen? In a multi-tenant product, where many customers share the same application, the honest answer depends on how the data is separated, where the separation is enforced and how much of the system sits outside the main database.

This guide compares separate databases, separate schemas and shared tables. It also explains which database products provide row-level security without a database or schema per customer. The examples are design guidance, not an audit of Oryvelon company infrastructure.

What a "tenant" actually is

A tenant is the unit of ownership in a shared system. In a B2B product it is usually an organisation: a store, a school, an agency. In a consumer product it may be an individual account or a household. The tenant is whoever the data belongs to, from the customer's point of view.

Define the tenant from the product's ownership and sharing rules. In a hypothetical store-management service it might be a store; in a school service it might be an institution. One person may belong to multiple tenants. Specify how membership, roles and deliberate sharing work before choosing a storage pattern.

Once the tenant is defined, identify which data is tenant-private, intentionally shared or public. Authorize every access against those rules; a tenant identifier alone does not grant permission.

Three patterns for tenant isolation

Most multi-tenant systems use one of three patterns, or a mix of them.

Separate databases per tenant

Each tenant gets its own database. The application connects to the right database based on who is signed in.

Separate databases create a distinct data container for each tenant. They still depend on correct connection routing, restricted credentials and controls around shared infrastructure. Export or restore operations can be scoped by database, but files, caches, replicas and retained copies need their own handling. A database boundary does not eliminate application or administrative access risks.

The cost is operational. Migrations have to run across every database. Connection pooling gets harder. Reporting across tenants, even for your own internal metrics, needs a separate pipeline. With thousands of small tenants, the overhead can outweigh the benefit.

Separate schemas per tenant

All tenants live in one database server, but each has its own schema: its own set of tables. The application sets the schema for each request.

A schema separates names and objects, but is not automatically an access barrier. In PostgreSQL, a role can access other schemas when its privileges permit it. Restrict privileges and review the search path; choosing a schema name does not authorize a tenant. Migrations and object management still need planning across schemas.

Shared tables with row-level isolation

All tenants share the same tables. Every row carries a tenant identifier, and every read and write is filtered by it.

Shared tables can reduce duplicated schema management, but cost and performance depend on the workload. If the application relies only on manually adding a tenant filter, an omitted filter can expose data. Database-enforced policies offer another enforcement point; neither model removes the need to secure credentials and validate the request's tenant membership.

Two examples with native row-level controls are PostgreSQL and SQL Server / Azure SQL Database. They can restrict rows inside shared tables without a separate database or schema for every customer. An application authorization service can decide which tenant a request may use, while the database enforces the corresponding row policy. A policy decision component alone does not automatically protect database queries.

Which product categories enforce which boundary?

Compare products by the access path they enforce, rather than treating every tenant-aware tool as interchangeable. A useful evaluation separates three responsibilities:

  • Database policy enforcement: native row-level security can restrict reads and writes in shared tables. Check table coverage, the actual application role and privileged bypass paths.
  • Application authorization: an authorization component can determine whether a user may access a tenant or resource. The application still has to enforce that decision on each relevant operation; a decision is not a database row policy.
  • Storage and retrieval controls: files, search results, cached responses and AI retrieval need their own scope checks. A protected database does not automatically protect a copied record.

In a hypothetical two-store application, changing the requested store identifier must not grant access. Test an ordinary store account against another store's reads, writes and exports, including direct database paths that bypass the application. Then test files and cached results separately. Record which component denies each attempt. A product category or a successful administrator query is not evidence that these boundaries hold.

PostgreSQL row security must be enabled on the table. With no applicable policy, normal access is denied. Superusers and roles with BYPASSRLS bypass it; table owners normally do too unless FORCE ROW LEVEL SECURITY is used. Test using the actual application role, and cover both visible rows and permitted writes. Do not assume a successful administrator test proves tenant enforcement.

SQL Server and Azure SQL row-level security use security policies and predicates. Filter predicates restrict visible rows; block predicates can reject prohibited writes. Check the product-specific behaviour rather than assuming PostgreSQL's owner or bypass rules apply unchanged.

Comparing the patterns

DecisionSeparate databaseSeparate schemaShared tables
Primary separationDatabase boundary and connection permissionsObject namespaces plus privilegesRow policies and trusted tenant context
Operating workManage a fleet of databasesManage tenant-specific objectsManage shared schema and policy coverage
MigrationsCoordinate per databaseCoordinate per schemaChange shared tables and policies
Export and deletionScope database work; include external copiesScope objects; include external copiesScope rows; include external copies
Cross-tenant reportingExplicitly authorized aggregationExplicitly authorized aggregationExplicitly authorized aggregation
Example reason to evaluateIndependent database operationsTenant-specific object organisationA common data model across tenants

There is no universally correct choice. The right pattern depends on how many tenants you expect, how sensitive the data is and what your customers are entitled to ask for.

Consider company and customer boundaries separately

A company group may need to consider two distinct boundaries: one between its businesses and another between the customers of each product. Treat this as a design question to document and verify, not as a conclusion about the group's deployed systems. See Shared infrastructure, separate data for related considerations.

The two boundaries call for separate questions.

Between companies. Identify data ownership, administrative access, credentials and any justified shared services. Assess whether a company could export its data or operate independently. A shared login or service should be an explicit design decision with documented access limits, not something inferred from a group relationship.

Between customers. Choose the tenant definition and enforcement model for the product's actual requirements. Record the reasoning, privileged exceptions and test evidence in its source-of-truth document. There is no universal tenant-count threshold that establishes the correct architecture.

Company-level controls and customer-level controls address different access paths. Review both: an authorized company administrator may still need restrictions on customer records, and a correctly filtered customer query does not secure a shared administrative account.

Where tenant data leaks in practice

Inspect the whole data flow, including the database and the services around it. Useful review targets include:

  • Caches. Tenant-private responses need tenant-aware keys or an equivalent isolated cache. Include other inputs that change authorization or content, and invalidate stale entries when access changes.
  • Search indexes. Enforce permitted scope before results, counts or snippets reach an unauthorized caller. Verify the actual search service's filtering and access model; a tenant field is not enough by itself.
  • Background jobs. A job queued with a record ID but no tenant context can run with the wrong permissions or write results into the wrong place.
  • Logs and error reports. Stack traces and request logs often contain payloads. If the whole engineering team can read all logs, the logs are a cross-tenant view.
  • Exports and file storage. A predictable file path or a public bucket defeats every database control.
  • AI context. If an AI feature builds its prompt from retrieved documents, the retrieval step is a data-access path and needs the same tenant filter as everything else. We cover this in RAG without data leakage.
  • Analytics. Review copied datasets, semantic-model roles, reports, cached results and exports as access paths. Product analytics that capture free text or identifiers can also retain tenant-private data; see the analytics section below.

A useful rule: derived data belongs to the tenant it came from. Summaries, embeddings, cached answers, aggregates and model outputs all inherit the tenant of their source.

Tenant isolation in analytics and reporting

Tenant isolation in analytics means enforcing the intended access boundary in the reporting path as well as the product database. A tenant field used to group a chart is not, by itself, authorization. Identify the source connection, copied datasets, report model, viewer roles, cached results and exports.

Database row policies and BI permissions protect different layers. For example, Microsoft's Power BI RLS documentation describes role-based filtering in a semantic model. In the Power BI service, it restricts workspace Viewers, but not Admin, Member or Contributor roles. Check the connection mode and actual viewer identity, and test the published report rather than assuming that a database policy automatically follows an imported copy.

For a hypothetical dashboard used by two stores, sign in with each store's ordinary account. Verify that charts, totals, drill-through views and permitted exports expose only the intended records. Repeat after changing membership, refreshing data and using a cached result. Missing tenant context must not turn into an unrestricted report. Review privileged support and analysis access separately.

Distinguish customer-facing reports from internal product measurement. Collect only useful events, limit identifiers and free-text payloads, and document any authorized cross-tenant aggregation. A dashboard filter, an aggregate chart or a separate analytics property alone does not prove that private source records are inaccessible. See Analytics without surveillance for measurement and data-minimisation considerations.

AI makes isolation harder, not different

AI features add retrieval, prompt construction, response storage and provider access to the data flow. If products use a shared AI gateway, its routing and authorization need explicit boundaries. This is a review recommendation, not a claim about a currently deployed Oryvelon gateway.

For tenant-private AI workflows, consider the following controls:

  1. Every AI request carries validated company, tenant and user authorization context.
  2. Retrieval searches only data the caller is authorized to access, including any explicitly shared sources.
  3. Response caches distinguish tenants and relevant authorization, content and prompt versions.
  4. Observability logs store what is needed to debug and measure — tokens, latency, errors, schema validation results — with tenant content minimised and access restricted.
  5. Document whether data may be reused or sent to a provider, and enforce the agreed restrictions instead of assuming them.

In a hypothetical store-monitoring feature, a refund summary should draw only on records the requesting store may access. Test that another store cannot retrieve the source records, generated answer, cached response or export. These are expected test outcomes, not a statement that a named product has passed them.

Enforcing the tenant boundary in code

Whatever pattern a product uses, a few engineering habits make the boundary hold.

Resolve and authorize tenant context. Authenticate the caller, verify membership and permissions for the selected tenant, and carry that context through the request and any background work. Recheck access when membership or scope changes; never trust a tenant ID merely because it appears in a URL.

Centralize the rules and cover every access path. Database row security and application authorization can complement each other. Identify paths that bypass the normal application layer and test them separately, including privileged jobs and direct database clients.

Fail closed. Missing or invalid tenant context must not expand access. The observable result may be an authorization error or no permitted rows; define and test the intended behaviour for each operation.

Make cross-tenant access explicit. Some internal jobs genuinely need to see across tenants — billing, support tooling, aggregate health checks. Give them a separate, named path with its own permissions and logging, instead of letting them bypass the normal layer.

Test for leaks on purpose. Create two synthetic tenants in test, sign in as one, and try to read, update, export, search and prompt your way into the other. Automated tests for this are cheap and catch regressions that code review misses. This depends on having good environments and synthetic test data.

Scope credentials deliberately. Review access by company, environment and service. Separate keys can limit the reach of a compromised credential only when their permissions and shared dependencies are also constrained. See Secrets management basics.

Choosing a pattern: a worked comparison

The following are hypothetical planning examples, not descriptions of Oryvelon deployments, customer contracts or legal roles.

A store-operations service. A common data model could make shared tables worth evaluating. Test row policies, store membership, service credentials and export jobs using representative workloads. Measure operating cost and query performance rather than assuming this is always the cheapest design.

An institutional education service. Review the actual data, administrative roles, contract requirements and deletion process before selecting a pattern. A separate schema alone does not establish a stronger security boundary. See child data minimisation for related questions; this example does not assign legal responsibilities to a school or vendor.

An individual decision-support service. An account might own private questionnaires and reports, with deliberate sharing where permitted. Minimise collection, but still authorize access to every retained record and derived output. Data minimisation does not replace isolation.

The pattern follows the data, the customer and the contract — not a group-wide default.

Common mistakes

Use the following failure scenarios in a design review; they are not a report of incidents in Oryvelon products.

  • Treating the admin panel as outside the boundary. Internal tools are often built fast and given broad access. They should respect tenants too, with cross-tenant views limited to the people who need them.
  • Tenant ID in the URL, trusted without checking. Changing a resource identifier must not grant access to another tenant's private record. Verify membership and resource authorization.
  • Shared caches added late. Caching is usually introduced for performance under pressure, which is exactly when the tenant key gets forgotten.
  • Assuming the vector database is "just an index". It holds tenant content in another form and needs the same controls.
  • One set of production credentials for everything. A single key that can read every company's storage turns a small mistake into a group-wide incident.
  • Deletion that only touches the main table. Backups, search indexes, caches and analytics need a deletion story too. See Data retention and deletion.

A tenant isolation checklist

Use this proposed checklist before launch and when changing features or access paths:

  1. The tenant is defined in writing, including edge cases (one person, two stores; one school, many campuses).
  2. The chosen isolation pattern is recorded with the reasoning.
  3. Tenant context is derived from verified membership and checked against resource permissions.
  4. Missing or invalid tenant context never grants broader access.
  5. Caches, search indexes, files and AI retrieval enforce the same authorization boundary.
  6. Logs minimise tenant content and are access-controlled.
  7. Cross-tenant internal paths are named, restricted and logged.
  8. Automated tests attempt cross-tenant reads, writes, exports and AI queries.
  9. Per-tenant export and deletion work end to end.
  10. Credentials have documented scope by company, environment and service.

Record the result of each check and revisit it after changes to roles, policies, storage or integrations. A checklist without observed test results is not evidence that isolation works.

Assess operating cost and access trade-offs

Include policy maintenance, tenant provisioning, migrations, access reviews, export/deletion work and test coverage in an architecture comparison. Reporting across tenants should require a documented purpose and appropriate authorization. A convenient shared dataset is not a reason to reuse customer data for unrelated marketing; see marketing and product consent.

Choose controls against explicit threats and requirements, then document what remains outside their coverage. No storage layout guarantees that a problem stays within one product: shared credentials, services or administrative access can connect otherwise separate stores.

Questions to ask any multi-tenant vendor

Ask vendors how their controls work in the product and plan you will use. Request evidence for the access paths that matter, rather than treating a general security claim as an implementation guarantee.

  • How is a tenant defined in your system, and can one of our companies be a separate tenant from another?
  • Is the tenant boundary enforced by the database, by a single access layer, or by individual queries?
  • Do caches, search indexes and any AI features respect the same boundary?
  • Can your support staff see our data, and if so, is that access logged and time-limited?
  • Can we export and delete everything for one tenant, including derived data?
  • Is our data used to train or improve features for other customers?

Vague answers are an answer in themselves. A vendor that has thought about isolation can usually explain its approach in a few sentences.

Summary

Tenant isolation is a set of access controls to design, test and maintain. Separate databases, separate schemas and shared tables organise data differently; privileges and application routing determine who can use it. Native row-level policies in PostgreSQL and SQL Server can support shared tables, while files, caches, jobs and AI retrieval still need their own controls. Choose a pattern from verified requirements, and do not treat a diagram or a product claim as proof that the boundary holds.

Questions and answers

What is tenant isolation?

Tenant isolation is the set of controls intended to keep tenant-private data available only to authorized callers. Review databases, files, caches, jobs, search and AI retrieval, and document any deliberate sharing.

Which databases provide row-level security for shared tables?

PostgreSQL and SQL Server, including Azure SQL Database, offer native row-level controls. These can restrict rows without a separate database or schema per customer. Policies, application identities and privileged access still need correct configuration and testing.

Is row-level security enough for a multi-tenant product?

It is one control at the database layer. Verify the actual application role and write permissions, then test files, caches, jobs, exports and AI retrieval separately. Application authorization filters are not the same feature as native database row-level security.

How should tenant isolation work in analytics?

Enforce access in the reporting path, including copied datasets, viewer roles, caches and exports. A tenant filter used for grouping is not authorization. Test with ordinary tenant identities and review privileged access separately.

NextChild data minimisation in edtech: what to collect, what to refuse and who decides →