In my business logic, I have a user, a company (users can be part of the company, as employees, i would call them "agents") and products.
A product can be owned by a user or by a company, the company can assign it to a user (agent) later, but it would still be owned by the company (in case the company fires the agent).
My thought is to have the user table, the company table and the product table and a table to track who is the owner of the product:
--------------
| users |
--------------
| user_id |
| name |
--------------
--------------
| products |
--------------
| product_id |
| title |
--------------
--------------
| company |
--------------
| company_id |
| name |
--------------
--------------
| agents |
--------------
| agent_id |
| user_id |
| company_id |
--------------
----------------
|product_owner |
----------------
| id |
| product_id |
| user_id |
| company_id |
|agent_assigned|
----------------
If the product is owned by a user then only product_id and user_id will be filled. If it's owned by a company, then product_id, company_id and agent_assigned would be filled.
Later, I would want to pull a product, and know who's the owner: the user info, or the agent and company info.
Is this the best way to do it? It doesn't seem that good to me.