Reputation: 129
I have Shop entity
I need 7 checkboxes to set working days for this shop on frontend
I'm looking for best solution to store values in db. The easiest method is to keep 7 boolean fields like "monday?" "tuesday?" ... in db
Can you help me? thanks
PS: it should be searchable (ex. i want all shops working today)
Rails 3, Postgresql 8.4
Upvotes: 3
Views: 1034
Reputation: 78523
Since there's little chance you'll have any kind of useful indexes on it, a bit(7) might be a good candidate depending the type of query you're doing. (And assuming AR supports it.)
Alternatively, boolean fields work - it'll just be a lot more verbose.
Upvotes: 0
Reputation: 10564
How are you going to use this data? If you need to find by working day(s) of week then do boolean columns as you say. If you don't, store as a string representation such as 'tttttff' (open monday to friday).
Upvotes: 2