Reputation: 215
I have a table with more than 12 columns which just have boolean items! How to manage this with a single column?
And as part of requirement, this needs to be dynamic (in the sense, the column may increase in future) so it should act without altering the table!
Whats the best way to achieve this?
Table Users:
married: False
profession_provided: False
location_provided: True
certificates_provided: False
exams_provided: True
Like the above i have more than 12 columns, and in near future this may increase - so is there any way to handle this - for example using Json or array or bitwise etc
I have read some article saying bitwise can be stored like this:
0010101
So if its 0 then false else true! Is this trustworthy or is there any effective way to handle this?
Upvotes: 0
Views: 644
Reputation: 656804
Here are a couple of space-efficient solutions:
An array of boolean
(bool[]
) would be another, still relatively space_efficient option.
If storage is of no concern, you might just add a document-type column (json
, jsonb
, or hstore
) to allow dynamic (schema-less) growth with more explicit storage of key and value.
Upvotes: 1