A very basic design question here. I would like to build a scalable app and would want to know what's the best way forward.
So in the database there are two tables : users
and companies
.
users
has the following fields:
-id
-name
-company_id
-join_date
-leave_date
companies
has the following fields:
-id
-admin_id
-address
I want a 1-to-M between users
and companies
as one company could have many users, but one user belongs to only one company. Also, I want to have a 1-to-1 on users
and companies
because one company has one admin and vice versa.
I'm not sure if I am tackling this right. The admin role would basically have more privileges on the system. But I cannot understand if it should be a 1-to-1 or not. Who would the parent be, etc.
users
(what if a company is going to have 2 admins?). In more complex enviroments a user will have 1 or more role and a role will have 0 or more users (many to many).