Skip to main content
Tweeted twitter.com/StackSoftEng/status/896521414962008064

Bundling of related boolean values for an sqliteSQLite database or keeping them separate?

I'm writing a reminder application where reminders can be shown or not for each day of the week (similar to google calendarGoogle Calendar). So I'd like to store the following in my sqliteSQLite database:

  • Monday: True or False
  • Tuesday: True or False
  • etc. for all seven days of the week

I could simply store one True/False value for each weekday. (sqliteSQLite doesn't have a boolean datatype, so I'd have to store it as integers in this case).

AnotherAn alternative would be to store a single integer between 0 and 127 (000 0000 and 111 1111 in binary).

(Normally i'd Normally I'd prefer the first solution since it's more direct, but, when there are so many boolean values I'm thinking, wouldn't it may be better to bundle them together)?

What should I consider when choosing between these approaches? Is there anothera better alternative?

Grateful for help and with kind regards, Tord

Bundling of related boolean values for an sqlite database or keeping them separate?

I'm writing a reminder application where reminders can be shown or not for each day of the week (similar to google calendar). So I'd like to store the following in my sqlite database:

  • Monday: True or False
  • Tuesday: True or False
  • etc for all seven days of the week

I could simply store one True/False value for each weekday (sqlite doesn't have a boolean datatype so I'd have to store it as integers in this case)

Another alternative would be to store a single integer between 0 and 127 (000 0000 and 111 1111 in binary)

(Normally i'd prefer the first solution since it's more direct, but when there are so many boolean values I'm thinking it may be better to bundle them together)

What should I consider when choosing between these approaches? Is there another better alternative?

Grateful for help and with kind regards, Tord

Bundling of related boolean values for an SQLite database or keeping them separate?

I'm writing a reminder application where reminders can be shown or not for each day of the week (similar to Google Calendar). So I'd like to store the following in my SQLite database:

  • Monday: True or False
  • Tuesday: True or False
  • etc. for all seven days of the week

I could simply store one True/False value for each weekday. SQLite doesn't have a boolean datatype, so I'd have to store it as integers in this case.

An alternative would be to store a single integer between 0 and 127 (000 0000 and 111 1111 in binary).

Normally I'd prefer the first solution since it's more direct, but, when there are so many boolean values, wouldn't it be better to bundle them together?

What should I consider when choosing between these approaches? Is there a better alternative?

edited title
Link
sunyata
  • 477
  • 1
  • 5
  • 17

Bundling of related boolean values for an sqlite database or keeping them separate?

edited title
Link
sunyata
  • 477
  • 1
  • 5
  • 17

Bundling of booleans inboolean values for an sqlite database or keeping them separate?

Source Link
sunyata
  • 477
  • 1
  • 5
  • 17
Loading