I am developing multi-tenancy application and I have no problem with the architecture itself. I find difficult on how to make customers table shareable among tenants. This is because same customer can subscribe to multiple tenants. I don't want to have same duplicate data and so user should register only once and be able to subscribe to any of tenant with the same credentials.

I have tried to look over the internet but could not find any good resource (may be I am using wrong keywords). I would appreciate any help (including the architecture name if any) to solve this problem.

If I am not clear please let me know.

  • You need to make a design decision on this. Either the multi-tenancy of your application will be completely invisible to both your tenants and their customers, or the customers need to be able to see that your tenants are hosted in your application and associate their account with more than one tenant. Mar 16, 2017 at 9:25
  • @Colin'tHart may be I was not clear. The decision is the customers should be able to see tenants and associate with more than one. I can't get my head wrapped around on how to do it. Mar 16, 2017 at 10:33
  • @McNets thanks for editing. Its exactly what I wanted to say. Kudos Mar 16, 2017 at 11:00
  • What part don't you understand? How to model the data? Mar 16, 2017 at 11:08
  • How that customers table relate to other tables in the rest of schemas. A very simple example can help me understand. In opaque multi-tenant I would have simply customer table per schema. But here it seems I need more than that and what I need more is what I cannot figure out yet. Mar 16, 2017 at 11:17

1 Answer 1


Multi-tenancy can be achieved in several ways; opaque multi-tenancy doesn't necessarily mean a design with one schema per tenant. It can also be achieved by adding a "tenant ID" column to every single table. As an example, this is the way that SAP has done it for a very long time already.

Applying this principle to your design, you would add "tenant ID" to all tables that need to be multi-tenant, while the "customers" table won't have it. Instead you need to add a "tenant_customers" table with two columns; "tenant ID" and "customer ID" to associate customers with tenants. Wikipedia calls this concept an Associative Entity.

Alternatively, you can store your tenant-specific data in one schema per tenant and have the customer table and "tenant_customers" associative table stored in its own schema. Instead of "tenant ID" you could use a string storing the "tenant schema name".

  • Thank you so much. The last paragraph answers my question in full and the rest expands what I already knew. Thank you! Mar 17, 2017 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.