kmnurunnabi's avatar

Tenant aware Model

If I decorate Single DB for all Tenants database design model do I need to check each of my model is tenant aware or it depends on scenario?

0 likes
5 replies
kmnurunnabi's avatar

@martinbean Specially in SaaS application if I want to separate tenants account using single database for all tenants concept, should I use tenant_id foreign key column for all others migration or I should use tenant_id based on scenario? Where I might no need to use that relationship reference

martinbean's avatar

@kmnurunnabi I still have no idea what you’re trying to ask.

If a model belongs to a tenant then yes, you will need to put a tenant_id foreign key to identify which tenant that model actually belongs to.

kmnurunnabi's avatar

@martinbean Yes. You are closed to my answer. I want to know should I avoid any model that may no need a belongs to relationship with tenant or its a best practice to keep relationship all other models with tenant?

Ben Taylor's avatar

Anything that's shared by all tennants doesn't need a tennant_id. Anything that is related to a model that is related to a tennant doesn't necessarily need a tennant_id, if it is not directly related to the tennant. You just need to make sure that private data is never accessed by those unauthorised to access it.

Please or to participate in this conversation.