I am working on a multi-tenant application that's using a shared Postgres
db for all tenants.
All entities in the DB are connected (directly or indirectly) to a tenant, for example:
Tenant --has many--> Buildings --has many--> apartments -- has many--> people
(just an example, let's not get into X shouldn't be an entity kind of discussion)
So if a client is trying to update the info of a person, I have to do few joins to link Person
entity to Tenant
entity to verify this Person
belongs to this client's tenant
.
I haven't reached any performance issues (yet), but if I am going down a path with a dead end I would prefer to know while data migration is relatively easier.
My question:
Should I link all entities directly to a Tenant
and end up with a de-normalized database? or the current design is a good one ?