Search code examples
sqldatabasedbnull

Should i set a column as NULL if there's records that will not use that specific column?


Does that make any difference?

Example:

I have a table with 5 columns, i use 3 columns for most things of my website, and 2 columns for the menu bar or anything else.


Solution

  • You can try to see if the table contain logically grouped data. If it doesnt, try to normalise. Alternatively, setting the field to default value of null and deal with Null on the programming code.

    Here is a good article on setting field to NULL:

    https://dba.stackexchange.com/questions/5222/why-shouldnt-we-allow-nulls