What are the different ways for storing multiple choices values in table? In a form i am having around 30 to 50 sub division in which each subdivision has around 5- 10 checkboxes. how do i design the database, one way to do it, store each field in the table set it to true or false but the thing i am finding it difficult to design is that if i design it this way, i will end up have around hundred columns. any insight about optimizing. how about using xml for the values in the checkbox instead using database.
Share
there are a few ways to solve this. the most common approach would be to store the selected value in table.
with this model you can add additional options and selected options are stored in the divisionoption table.
another approach would be to assign binary values to each option and then sum the options and store the value in a single field
when it’s time to save add up the values and store them in the division table.
example
option 1 – 1
option 2 – 2
option 3 – 4
option 4 – 8
user selects options 1, 2 & 3.
save the value 7 (1+2+4) to the division table.