In my application, I'd like the user to select his working days. then store them in the database. Of course my application will process the users' data like: Is today a working day for a specific user, who are the users that should work today , ... etc.
My question is, what is the best practice for doing this? should I use:
I would say that bit mask fields are a relational anti-pattern.
A field should have a single meaningful value, otherwise you end up with querying issues - parsing the field every time you need to query using it.
Such a field also requires extra documentation, as the values it stores are not self describing.
Bitmasking field is a bit more cryptic in nature and you need to create something else to interpret what you store in the bitmask.
The second approach is a lot more transparent and easily understandable and it's a bit more flexible if you need to add more values. With the bitmask, you again need to redo your bitmap decoder each time you add a value which can be a maintainance nightmare compared to the relational approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With