It seems approach 2 works. Could you confirm I am doing this correctly
What I am doing is creating a reference from Main Tenant File to each individual file and adding the TenantId to each file.
So MainCompany to Customer, MainCompany to Stores, MainCompany to User. The MainCompany has an auto increment TenantI when created. So when I am doing a query say on the customer its Customer.tenantid= LoggedInMainCompany.TenantId
The thing I was not sure about is if I just references the file, was there a way to do it without having the tenantid? But I think using the tenantid is easy and you could see it in the file.
I have one other issue. A user could be tied to multiple tenants. So Tenant is multiple and user is multiple. When a user logs in, if they are tied to multiple tenants, they have to select the tenant they want to work in. My thought on this was when selecting a tenant, to change the tenantId in the user for that session so all the queries work. Does that make sense?
This would complete an email type login system, allowing one user to work in multiple tenants which is real world possibility. In my case, an accountant might have access to the books of multiple clients running the system.
Appreciate the feedback if this whole approach makes sense, is not flawed, so I may move forward with the proper foundation.
Thanks,
Mark