Shall I use NULL''s or not?

  • Hi all, I know you have probs read this a million times, but I have to design a database where there are columns in my tables that can possibly contain NULL values (not require a value), so is it best to allow NULL values, or to not allow NULL values, but to have blank (empty string values)??

    I know NULL cause a problem with the COUNT() function, and some mathmatical functions, but I am referring to string based columns, and Foreign key (int) columns.

    Thanks in advance.

    Tryst

  • Only use nulls if your application requires it. It NULL is a valid value, meaning Unknown then use them, other wise avoid them by placing default values.

     

  • I would add that foreign keys should never allow NULLs. Sort of defeats the purpose of an enforced relationship.

    --SJT

  • Bull shit.

    Sorry, but I cannot find more adequate definition.

    _____________
    Code for TallyGenerator

  • Wrong.

    NULL cannot be valid value.

    NULL means absence of a valid value.

    Never replace NULLs with default values.

    Middle Name = NULL means that Middle Name for the person is not recorded (unknown).

    Middle Name = '' means that the person does not have Middle Name.

    Birth Date = NULL means that we don't know birth day and age of the person.

    Birth Date = 0 means that the person is 106 years old.

    Feel the difference.

    It does not mean that you are not allowed to use defaults.

    When you create a record for a new customer it's pretty logical to assume that this customer gonna be "Active" by default. So you can set up default value for column "Active" in table Customer as "1".

    But never use defaults as a replacement for NULLs. You gonna put yourself in trouble sooner or later.

    _____________
    Code for TallyGenerator

  • Hi all,

    and thanks for the replies.

    I guess it will be a design decision in a sense then, so i will give it some thought.

    Tryst

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply