I’m currently creating a permissions table which replicated the “777” method used in linux.
To do this I wanted to create a table like:
user_id, class1, class2, class3
Where class can be some feature on the website which requires permissions.
Does this seem like a good way to go about it? Are there an problems with this method?
Also, which datatype would best suit this data. I could use INT(3) but I’m assuming there’s no “binary” datatype that replicates this type of thing
Use
set('ru', 'rg', ro', 'wu', 'wg', 'wo', 'xu', 'xg', 'xo', 'sgid', 'suid', 't')This is bit-optimized.
However, if you need to filter on individual permissions (like “select all users who can read from here”), you better implement it as a plain many-to-many tables:
with each permission in its own record, create the
PRIMARY KEYconstraints:and query: