I recommend using a bitmask for the following reasons:
- Index cannot be used effectively.
- Inquiry more difficult
- Reading / service has been hit hard.
- The average developer there does not know what a bitmask is.
- Flexibility is reduced (upper limit to nr bits in number)
Depending on your query patterns, planned feature set, and data distribution, I would go with your option 1 or even something simple:
user_permissions( user_id ,read ,create ,download ,print ,approve ,primary key(user_id) );
Adding a column is a modification of the scheme, but I assume that adding the “Cleanup” privilege will require some code from the code, so the privileges may not be as dynamic as you think.
If you have a sick data distribution, for example, 90% of the user database does not have a single permission, the following model also works fine (but falls apart with large scans (one five-way connection versus a single scan of a full table).
user_permission_read( user_id ,primary key(user_id) ,foreign key(user_id) references user(user_id) ) user_permission_write( user_id ,primary key(user_id) ,foreign key(user_id) references user(user_id) ) user_permission_etcetera( user_id ,primary key(user_id) ,foreign key(user_id) references user(user_id) )
Ronnis Apr 18 2018-11-21T00: 00Z
source share