Table for site options -- how to handle multiple value types?
I'm creating a (MySQL) table for site options, that will have multiple key/value rows (option_name, option_value). Some values will be boolean, some will be strings(varchars) and some might be int. Currently I have option_value set up as a varchar so that it's able to store all the values. Is there a better way for this? I was thinking of having 3 rows (enum for true false, int for int_value and varchar for string_value), however that seems inefficient. Is there a better way and/or am I doing this wrong?
I'd prefer to have the three different columns representing the value types, as opposed to having just one over-loaded column. I like the fact that the 3 columns are sort of self-explanatory (assuming pertinent naming), and that I wouldn't have to write some sort of adapter to correctly handle the 3 values types that are stored in a single column.
Asked in February 2016Viewed 1,665 timesVoted 11Answered 1 times