I'm building a multi-tenant application, on top of Postgres/MySQL:
- Single DB;
- Single schema;
- Using tentant_id on every table.
I'm confusing how to make it happen to have shared data between tenant, like defaults data like credit cards brands. All tenants will see this default credit cards brands. BUT, they can delete specific brands on their accounts.
So, I have the tables:
- tenants
- credit_card_brands
Possible solutions I reach out:
- default values of credit_card_brands can be tenant_id = NULL, but how the tenant delete? (use a tenant_excludes field?)
- create another table (pivot table), tenant_credit_card_brand with the relation with that
My concerns is to run away for duplicate data, and be easy to maintenance. Example: If i have to add a new default value to all the tenants, I only insert on a table.
My question: How can I create this architecture? A tenant can view default data, can delete them (only on their accounts), and insert/delete specifics ones (in their account).
Thanks a lot!