I'm modelling a database schema that has the requirement of including a multi-user account facility for premium customers:
A multiple account enables multiple users to login to the same account
in order to do the job according to their permission level. This means
that it is possible to maintain a single account for your entire
marketing team. The account owner can add as many users as he/she
wants and limit what permissions each of them has. You can choose role
for each user: account manager, marketing executive, marketing
assistant, etc… or create a customized permission.
At the moment I have one users table that stores the information of a generic user with the username and password etc. How would one implement a multi-user account facility? Could an extra field be added to the users table? Would a separate table be required? I would like to use the principle of keeping this simple where possible.
Best Answer
You should have an accounts table and a users table, with either a one-to-many or a many-to-many relationship between the two.
As an example of the many-to-many relationship:
The
UserLevel
represents the type of account access; account manager, marketing executive, marketing assistant, etc.The one-to-many relationship would look like:
Insert some sample data:
Query combining the three tables:
Results:
Cleanup: