After reading Database design: 3 types of users, separate or one table? I am confuse on how I should design the database.
---------------------- 1st Design ----------------------
USERS
- username (PK)
- password
- account type (Admin, Manager or Worker)
PRO: When log in I can easily retrieve if this user is Admin, Manager, Worker
CON: I cannot form relationship (ONE Manager to MANY Workers) using this design.
---------------------- 2nd Design ----------------------
USERS
- username (PK)
- password
ADMINS
- username (PK and FK to USERS.username)
- password
MANAGERS
- username (PK and FK to USERS.username)
- password
WORKERS
- username (PK and FK to USERS.username)
- owner (FK to MANAGERS.username)
- password
PRO: Relationship can be formed
CON:
- When log in I have to find if user is Admin/Manager/Worker by looking in each of the table.
- It is also hard to enforce if one username appear multiple time across ADMINS, MANAGERS and WORKERS (BIG CONCERN!!!)
I have been spending several hours searching google for good design but couldn't find any solution. I am sure this kind of requirement is quite common? Please provide some insight! Thank you!