I would do it like this.
table name: permission columns: id, permission_name
and then I can assign multiple permissions to the user using the many-many relationship table
table name: user_permission columns: permission_id, user_id
This design will allow me to add as many permissions as I want and assign them to as many users as possible.
While the above design comes with your requirement, I have my own ACL implementation method in my application. I post it here.
My ACL implementation method is as follows:
- The user will be assigned a role (Admin, guest, staff, public)
- The role will be assigned one or more permissions (user_write, user_modify, report_read), etc.
- Permission for the User will be inherited from the role that he / she is
- A user can be assigned by permission manually, except for the permission inherited from the role.
For this, I came up with the following database design.
role I store the role name here +----------+ | Field | +----------+ | id | | roleName | +----------+ permission: I store the permission name and key here Permission name is for displaying to user. Permission key is for determining the permission. +----------------+ | Field | +----------------+ | id | | permissionName | | permissionKey | +----------------+ role_permission I assign permission to role here +---------------+ | Field | +---------------+ | id | | role_id | | permission_id | +---------------+ user_role I assign role to the user here +---------------+ | Field | +---------------+ | id | | user_id | | role_id | +---------------+ user_permission I store the manual permission I may allow for the user here +---------------+ | Field | +---------------+ | id | | user_id | | permission_id | +---------------+
This gives me more control over the ACL. I can allow super administrators to assign permissions, etc. As I said, this is just to give you this idea.
source share