View Full Version : bit-fields or set-type

03-01-2007, 07:41 AM
I'm trying to manage user privileges. My first thought was to use bit-fields. Something like:

// 1 = READ
// 2 = WRITE
// 4 = CREATE
// 8 = DELETE

// Get users whit read,write,create and delete rights:
SELECT userID FROM users WHERE privs = 15;

And using bit operators to set/get different privileges...

But then I remebered the SET-type (I allways forget about it). Which is the better to use? Personally I think the bit-field is pretty easy to manage, but which has the best performance? My guess is that the SET-type uses a bitfield anyway.... Anyone that knows what's happening behind the scene?