mysqldatabasesql-null3nf

Can I have nullable attributes in a third normal form database?


I have a nullable winnerID attribute which is constantly updated according to the bidding of an auction.

This attribute is set to save sometime in the end to calculate who won the auction. But this value is null initially.

Will this violate Third Normal Form?

Rule 4 of 1NF states that I cannot have nullable attributes, but the note says this is a controversial statement.


Solution

  • The way nulls are defined in SQL - as non-values which can't be compared with domain values - means they violate 1NF (and all higher normals forms). A relation (the mathematical structure represented by normalized tables) must have a single value for every column for every row. Nulls mean we have no value, and a nullable column means we have two relations in one table - a supertype relation which includes all the columns except the nullable one, and a subtype relation which has the same primary key and the previously nullable column, for which we can record only rows for which the attribute is known. The purpose of normalization is to factor a data set into elementary facts without losing information, so having two relations in a single table contradicts the objective and makes things like relational algebra/calculus more complicated.

    The normal forms are formal logically defined structures, not industrial best practices which can be adapted to the situation, so I don't see much space for controversy. Whether we should use them and how they should be handled is a more interesting topic.

    While nulls violate the normal forms, it doesn't mean you can't use nulls in your SQL database. They have risks as well as benefits. I use them too, but with consideration.