Storing and Accessing a Range of Numbers / Dates in MySQL -
i need store range of numeric or datetime values in mysql, preferably in single column. unfortunately, there no real array or set data-types in mysql, likewise seems there no range data-type, i'm bit @ impasse here, hoping come smart.
common use cases range e.g. storing start , end times of event, or minimum , maximum prices of given product.
in case, need store year(s) book written. in cases, there ambiguity , year have on record may e.g. 810-820. of course 1 way go have separate year_min
, year_max
columns, , have identical data stored in both columns in case there no variance.
yet fraction of entries have need have such range stored, , i'd love query simple between 750 , 850
example -- , avoid both having where
hit on 2 columns, redundant duplication of data in 98% of cases.
what's recommended approach? best practice tips? know how tune decent two-column queries. i'm hoping there's way go this... (and no, i'm not switch postgresql just have benefit of range types.)
i recommend going 2 column solution, despite not sexy or clever. suppose implement 1 column. database becomes non relational, because given record , column points multiple values (year_min
, year_max
). though schema might appear tidy, might lose benefit in form of more difficult queries.
Comments
Post a Comment