- There are some business category e.g. Travel Agency, Hotel, Car Rental etc.
- Roles:
- Management rolesSuper Admin, Staff
- Customer side roles are Owner, admin and sales counter
- May be etc. customer side roles will be added
- Status i.e. On-Hold, Active, In-Active, Blocked, Deleted etc.
- Scenario:
- Each user in the database has its role and status with other credentials
- Super Admin or Staff creates a customer (USER) with category e.g. "Travel Agency" and provide owner details
- Now this Travel Agency (USER) has its own SUB_USERS that may be one or many
Now I am confused between user and sub users.
The work that I done so far is as following in shape of ERD:
Please put me on the right path as to how can I create a USER with its SUB USERS?
Thanks in anticipation
Best Answer
Why not just get rid of the
main_user
andsub_user
tables and have a nullable field on theusers
table calledparent_user_id
. Then you can use a self-join onusers.parent_user_id = users.user_id
to get all the sub-users for a given Travel Agency. (When theparent_user_id
field is null, that's a Travel Agency.)