views:

45

answers:

3

hello everyone.

Im current implementing the permission like this:

Permission                UserPermision               User
-------------------      ----------------------       -----------------
PNAME PID                 PID  UID  PVAL              UID UNAME

This concept work fine, but at somepoint, we will want to add a Permission grouping like admin, guest, power user, or something like that.

Can anyone suggest to me a good way to lift the current Permission database to implement the permission grouping?

Thanks in advance

+2  A: 

Only give permissions to roles. (if you want to be very fancy give it to either role or userid, but it is nightmare on maintenance as it scales).

So perms map n-n to roles, roles map n-n to users.

Permission         
-------------------
PNAME PID          

User Role
-------------------
UID ROLEID

Optional Role
-------------------
ROLEID ROLE_INFO

Permision Map         
----------------------       
PID  ROLEID  PVAL        

User
-----------------
UID UNAME
DVK
this is good to go. do you think there are any other solution?
DucDigital
No, I don't think so. BTW, what exactly is so different between my answer and the one you accepted other than I called the groups by their correct designation, roles?
DVK
+1  A: 

An alternative could be to introduce a new Group table and create a GroupPermissions/UserGroups table to map permissions to the specific group and users to that group. You can then use your UserPermissions group to include individual permissions if required (on top of the group permissions)

Groups
------
GID GNAME

GroupPermissions
----------------
GID PID

UserGroups
----------
UID GID

GroupPermissions - GID/PID would make up the unique row identifer to ensure you can associate multiple permissions to a single group.

UserGroups - UID/GID would make up the unique row identier to ensure you can associate multiple groups to a single user.

James
This is pretty good, i think i will go on with this idea. Thanks for this :)
DucDigital
Yeah it basically means you can assign users to groups and have permissions predefined, but also include special permissions for specific users.
James
A: 

You could enable you development db to "remember" the permissions it has had on different objects and keep them during development time regardless of how-many times you drop and create an object ...

YordanGeorgiev