Reputation: 979
I am using Ruby on Rails, but I think this question could be applied to any database design. I am trying to develop my own permissions system.
Is it poor design to have an array of what a user can edit? i.e. a User
has a column of can_edit
with a value of [Articles, Events, Costs]
or a User
can_view
with a value of [All]
.
And then I can just run a check on what is being edited. Or is this poor design?
Upvotes: 0
Views: 365
Reputation: 231671
In general, your database design ought to be properly normalized. That would mean that you shouldn't store multiple values in a single row. You'll likely be much better served by a design that has three tables
Permission
has columns permission_id
and permission_type
and lists the valid permissionsUser
has a user_id
column and lists the value usersUser_Permission
is a mapping table between the two. It has columns permission_id
and user_id
both of which are defined as foreign keys to the Permission
and User
tables respectivelyUpvotes: 2