How's should I design database when there's 2 type tenant?
I am currently using stancl/tenancy package with single database.
I have 2 type of tenant which consist of different information. For now, I am going to create in this way to store the different data info for tenant.
domains
id | domain | tenant_id
tenants
id | type
tenant_type_1
id | tenant_id | ... related column here
tenant_type_2
id | tenant_id | ... related column here
tenant_user
tenant_id | user_id | user_type
I am not sure is this the correct way, should I do it in this way? Appreciated if any feedback and suggestion. Thank you.
@zidance Is this really a multi-tenant application, though? Or just a two-sided marketplace?
Think about Uber. Uber has riders and drivers. I can sign up as either a rider or a driver (two sides to the same marketplace). But Uber isn’t a multi-tenant app. There’s only one Uber.
@martinbean Erm,yes. I treated it as a scope at the moment. But my brand here is like a company a group while influencer refer to a single people. I am just curious how should I store the data for brand and influencer for the purpose if I am going make it in this way. It might similar to two-sided marketplace to the same marketplace, but the concept more like Shopify way.
Not sure if I am doing it in wrong way? In easier way, it could be like create a table companies and influencers, which store relevant pieces of data into relevant table and create scope trait and applied to the related model when query.
@zidance I think you’re maybe over-complicating things in that case.
It sounds like you’d have a company. A company could have many users (many-to-many relation). An influencer is just a single user as well.
I don’t know what your application does but you could have your “influencer” users create an influencer profile. If they have this related profile, they’re an influencer. If influencers promote products from a company or whatever, then have another many-to-many relation between influencers and companies.
You now know which application users belong to a company, and which companies an influencer user is associated with/promoting products for.
@martinbean hmm, because I am assigning unique subdomain for them when creating them. So, I am thinking to try out the package. Maybe, it's too over...