• Robert Mark (10/30/2014)


    I have two other considerations for NULL vs NOT NULL.

    1) If you're application coding language requires checking for null values when you read in data from the database, this is a lot of extra coding and is a good reason to have NOT NULL columns.

    2) Use of default values for columns. To avoid needing NULL values, it is easy to set a default value for every field in a table, this allows you to not need to check for NULL values in your application for most queries (except for some aggregate or outer join queries). So a numeric field can be defaulted to 0, a date to a specific date in the past or future, a string to a blank value or

    'Unassigned', or 'Not Specified', etc.

    So using NOT NULL columns with default values keeps your database clean and the data within the tables predictable for your application. I know that default values can slow down insert operations, but for most applications this is not an issue.

    Well but default values don't always make sense for some columns, for example what about a balance field on an account, a 0 balance would mean something very different than a NULL and there might not be an appropriate value for a default.