Create null values with SQL Server
At the beginning
Many developers understand the term "null" well, but have not been able to handle null values well in the database.It is important to properly deal with NULL values in preserving the effectiveness of data.At least if the processing of the null value is incorrect, the data will occur.If you miss this bad data, you may make a business decision that doesn't work.
The concept of null is often interpreted by mistake.Some experts can describe null as empty value or empty value.In other words, the entity has no value in the entity.There are also experts who express NULL values as unknown values.It is unknown at the moment whether the value exists or not.In light of the Ansi standard, null is not a data value, but an indicator that indicates that there is no data.
Let's apply the concept of NULL to the actual data.For example, while checking a new customer record, the fax number or mobile phone number is not displayed, even though the phone number is displayed.At that time, I don't know if new customers do not actually own faxes or mobile phones, or just forget to enter data.If it was properly processed, this null would have made it important, but it was just unknown.
Process null
There is no rule that the method of processing null is correct and which is wrong.The important thing is consciousness and consistency.At first start at the table level.For example, in appropriate regular tables, nulls of telephone number are usually excluded.In the first place, no fax number or mobile phone number record is created until the user enters information.
However, all NULL allowed type (nullable) cannot be excluded by normalization.In such a case, the null value is excluded at the column level by making the value required.In addition, it is necessary to determine whether to set the default value or allow a string with zero length.But still, some will hit NULL allowed rows.In some cases, this problem is unavoidable due to business rules, or such a column is used in legacy applications.