C
C#15mo ago
Tandy

❔ Multi-tenancy - database per tenant - which database(s) to store Users?

We're using Auth0 for authentication. A given User could have access to multiple tenants. I'm envisioning a Catalog database with Tenants table and Users table, as well as a UserTenants table that links the two. However, I imagine that the tenant databases will require user information, like first name, last name, email, etc, for business logic. So does it make sense to have a Users table in both the Catalog database but also in each tenant database?
2 Replies
JakenVeina
JakenVeina15mo ago
I'm definitely gonna lean towards "no" if these were fully-separate applications, that would probably be different it would definitely make sense to keep a "cache" of user data in your own database, so you can serve up most requests without needing external queries definitely a more complicated job of needing to maintain sync on that cache but within the same application, and even the same database server almost certainly a "no" from me it's functionally the same as a large application having lots of internal microservices query for tenant info and user info separately, and tie them up in the business layer if you encounter a performance issue with the extra querying, you can introduce caching the one other downside I can think of is that you lose some amount of data integrity in the tenant databases, since you can't put an FK constraint on UserId columns which you can get around by just introducing a table with nothing BUT UserId in it I.E. "here's a table of the users that are authorized for this tenant, or have used this tenant before" but no need to duplicate all the user DATA
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.