In my DB, I have currently float data. All column are set to be NULLABLE and when value is missing I put there NULL.
My DB is too big and if I know, that values are in range 0 - 100 they can be rounded to 1 decimal place. So using float is overhead and I am thinking of use smallint (multiply every float by 10 and store it as rounded number). Now, what about NULL values.
I have two options:
still use
NULLuse some "out of bounds" value, like 9999, to represent
NULL(and also make this value default, when nothing is set for column). However, in my queries, I need to do this:SELECT AVG(NULLIF(data, 9999)) AS data, ....(When I use
NULL, i can just useAVG(data), whileNULLvalues are not computed..)
What is better to use. Or is there a better technique?