I am currently thinking of a way to store checkbox values (true/false) in a database, without using a boolean column for each checkbox. Is there a way to store them in a byte that contains the information for, let's say, six checkboxes?
For example:
* Checkbox 1 to 6 all unchecked would be 00000000
* Checkbox 1 to 6 all checked would be 00111111
* Checkbox 1 checked, rest unchecked would be 00000001
* Checkbox 3 and 4 checked, rest unchecked would be 00001100
* etc.
BEFORE EDIT: "In the end there would be one byte column and for each row a different combination for checkboxes checked/unchecked."
AFTER EDIT: Oh I see I've been unclear. I didn't mean that each possible combination of checkboxes is stored in the table in different rows, like a lookup table. It's more like, the whole table contains information from a user entry in a formular and the checkboxes which were checked by the user are just one element of the form (one column of a db row). Therefore each user entry of the form (a row) CAN contain a different byte in the checkboxes column. But if more users chose the same checkboxes, the byte in their row would look the same of course.
Would this make sense as an alternative to a bunch of boolean columns (one for each checkbox)?
Is there a better way to handle checkbox values in the db?
Is there a way to set each bit of a byte manually in C#? I can't seem to find an explanation on how to do this.