One Database Field to Hold Survey Answer
- by yar
Skipping the question of whether this is bad design (and the question of why I would want/need to do this), I'm just wondering if my 'math' is right...
I have n things that need to be put in order (n is always less than 5):
thing1
thing2
thing3
...
and I'd like to store these results in a single integer for thing. My initial thought is that (obviously the code will not look like this):
thing = thing1 * 1 + thing2 * 2 + thing3 * 4 + thing5 * 8
will always give me a unique value, and that any value for thing will always translate back to its values for thing1...thingn. Is this correct?