DEV Community

Discussion on: How do you handle the data ownership of a multi-tenant product?

Collapse
 
muthandir profile image
muthandir • Edited

Great documents, let me also share an article from Michael Beardsley. In my case I think there is a challenging complexity, (lemme see if I can describe it properly)

As Kasey mentions it is about the shared access (I liked the graph idea btw).

Personas:
-Company employees
-Travel Agency Consultants
-Hotel Front Desk Team

Company employees can create bookings.
Travel Consultants can review and make modifications on the bookings.
Hotels can review and make modifications on the bookings.

  • booking1    company-A      travel-agency-B  hotel-C
  • booking2    company-B    travel-agency-C    hotel-C
  • booking3    company-C    travel-agency-B    hotel-D

so

  • hotel-C can read booking1 and booking2,
  • travel-agency-B can read booking1 and booking3,
  • company-A can read booking1 only.

I think this is a fairly complex use case, and in this scenario, I've gone with 3 microservices (companyApi, agencyApi, hotelApi) that pass different tenancy information stored on different columns in the DB. Kind of similar to Michael Beardsley's post above (section: Alternative approach):

If you don’t want to create and maintain PostgreSQL users for each of your tenants, you can still use a shared PostgreSQL login for your application. However, you need to define a runtime parameter to hold the current tenant context of your application.