Is it good practice to have relationship between the tenant table and all other tables in a multi tenant application?
1
vote
1
answer
397
views
I am developing a multi tenant SaaS that uses Azure SQL for data storage. I make use of sp_set_session_context to make sure that any query only touches records relevant to the current tenant.
I occationally get requests to delete a tenant from the database. That means the record in the Tenants table and all other records in other tables with the same Tenant_Id. Today I do this with one DELETE statement per table.
Is it a good idea to create a relationship between Tenant and all other tables? This way I could use cascade delete to delete a tenant by simply removing a single record from the tenants table.
I am concerned about the more difficult recovery in the case of a mistakenly deleted tenant. I also want to be confident that there will be no serious performance issues with such a schema.
Asked by Gabriel Smoljar
(119 rep)
Aug 17, 2018, 04:04 PM
Last activity: Apr 15, 2025, 05:02 PM
Last activity: Apr 15, 2025, 05:02 PM