I have a group of checkboxes where the user selects some of the weekdays (the opening days of a store). How can I save the selected days? Should I save something like 0111111 (zero means closed on sunday) on the same field and split the result when reading the data? Or create a field for each day and store 0 or 1 on each (weird)?
The first approach saves space, the second improves performance while retrieving data, especially if you need to filter by individual weekday. It also makes the queries that manipulate weekdays a way clearer. You have to decide what is more important to you based on the application's logic.
In general, I'd use field-per-day solution.
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