I'm designing an RBAC model (role base access control) and have a couple of questions.
I have a permissions table where you can add a object (forum, profile etc), group, and the permission
Example:
Forum object has admin group with permissions can_post, can_view, can_edit.
Forum object has user group with permissions can_post only.
These are represented as rows.
The problem is that this feels like an EAV model. I think permissions should actually be columns...not rows.
Thus, the forum_permissions table could instead be...
CREATE TABLE forum_permissions
(
forum_name VARCHAR(25)
group_name VARCHAR(25)
can_view_topics CHAR(1)
can_view_posts CHAR(1),
can_create_post CHAR(1),
can_edit_post CHAR(1),
can_edit_any_post CHAR(1),
can_create_poll CHAR(1),
can_edit_poll CHAR(1),
can_edit_any_poll CHAR(1),
can_vote_poll CHAR(1),
can_delete_post CHAR(1),
can_delete_topic CHAR(1),
can_delete_any_post CHAR(1),
can_delete_any_topic CHAR(1)
can_delete_poll CHAR(1),
can_delete_any_poll CHAR(1),
can_move_topic CHAR(1),
can_move_post CHAR(1)
PRIMARY KEY (forum_name, group_name)
)
Now the problem is that it could contain too many columns once the permission set gets large. Also, what would happen if the client wanted to add a new permission in production? With the EAV model, it would be as simple as inserting a row into the permissions table.
Any suggestions?