In trying to implement role based security for a web app, I have a table in the database for Permissions, Roles, Users and UserRole (i.e the assignment of users to roles).
Each role has a set of permissions. The permissions are defined as a C# flags enum with values such as 0, 1, 2, 4 and so on.
In the database the role table has a int field which stores the combined permission flags for the role. (This way we avoid having a separate Permissions table (is that good or bad?) and a one-to-many table for RolePermissions.
In the code, I check if a user has access by calculating the effective permissions for the role(s) the user is assigned to. In .NET it is pretty easy to do that by doing logical operations on the enum flags.
So my question is:
Is there a disadvantage to doing it this way (as opposed to having a Permission table and RolePermission link table (that contains 1 record for each permission given to a role)?