I'm modeling a MySQL database and it has a users table with the columns:

  • username
  • passhash
  • permissions

The access crontrol will be made on programming level (NodeJS).

Each user may have a different combination of permissions to modules M#.

One user may have permissions to access M1, M2, and M3. another user may have permissions to access M2 and M4, and so on...

I would like to know what is the best way to store that kind of information.

I read a long time ago about the binary thing like:

000010001 - permitted access to M0 and M4

010000100 - permitted access to M2 and M7

000000011 - permitted access to M0 and M1

I am confused on how to store and retrieve that information. What datatype would be suitable for that purpose?

  • Sounds like you might use the BIT data type – mustaccio May 31 at 17:40
  • Or SET or INT (and use boolean operators) – Rick James Jun 1 at 3:17
  • It would be nice if you guys could show an example. – Azevedo Jun 1 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.