I have a problem figuring out the relations between some of my database tables. The scenario for this buisiness case is a b2b buissnes.
I have 3 tables:
A Company has multiple users (1 to many) A Company has mutltiple distributors (Many to Many) A Distributor has multiple companies (Many to Many) A User has 1 company (Many to 1)
Now im getting stuck on the next step.
I've build some roles and permissions into the system.
A user can be: - A distributor - A Company (manager) - User
In the perfect scenario a user can be a distributor or a company. How can i make this possible in just the database. I thought of a solution but it isnt the best solution. It would make it that the user would be in a OneToMany relationship with the company and the distributor. The relation could be null to that when a user is a company the relation with the company will be set. If a user is a distributor the relation with the distributor will be set and the company relation will be null.
I dont think that would be the best solution but i cant figure out a better solution.
How can i make it that a user can be a distributor or company without setting the relation to 0.