I will be storing draw numbers (1-60) in fixed values and fixed order.
One draw has 4 numbers
another has 6 numbers
and another 2 numbers
My idea was to separate each draw type in a separate sql table. The question is, would it be optimal to store the numbers in a single column separated by a delimiter….
ID(int) | numbers(varchar)
or store each number in a separate column instead?
ID(int) | num1(tinyint) | num2(tinyint) | num3(tinyint) | num4(tinyint)
I won’t be needing to search for the numbers when they’re stored.
If you don’t ever need to search for them separately or retrieve them separately, then they are just one opaque “blob” from the database perspective and you won’t be violating the principle of atomicity and the 1NF by storing them into single filed.
But, just because that’s the case now, doesn’t mean it won’t change in the future. So at least use the second option. Also, this would allow the DBMS to enforce the integrity of domain and ensure these are actually numbers and just any strings.
However, to future-proof your data, I’d go even further and use the following structure:
In addition to treating numbers in the uniform way and avoiding many NULLs, it’ll also allow you to easily vary the max. number of numbers if that ever becomes necessary. I suspect querying will also be easier in this structure.
BTW, if there are no
(other fields)and a draw cannot exist without at least one number, you can dispense with the DRAW table altogether and just use DRAW_NUMBER.