I'm creating an application that has a similar roles and permissions system to Discord.
- Users are members of groups
- Groups have roles
- Roles have permissions
- And users can be associated with one role at a time.
I'm not sure how to design a system like this. Originally, I was thinking I'd have a
roles table, and for each permission there would be a boolean column like:
That doesn't seem right though...
If you have any recommended reading, or can offer an answer with details on why it's done that way, I'd really appreciate that.
USERis a member of 1 or more
GROUPcan have 1 or more
ROLEcan have 1 or more
USERcan only get
PERMISSIONby being assigned a
GROUPwill share common permissions based on what features and content types the application has made available
ROLEScan share the same
So it looks like I'll need a table for both ROLES and PERMISSIONS. Now I just need to find what the
PERMISSIONS table would look like.