-1

I'm designing a new database and currently there a many fields that end up with the value NULL.

I've read about NULL vs "" and I think that "" is preferred.

Should I go to the effort to ensure there are no NULL values - it would only take a few hours?

Is this worth the effort - Note: I will be working with this database for many years to come.

thx

Adam
  • 19,932
  • 36
  • 124
  • 207
  • 1
    personally I don't like `nulls` unless really needed. Any column with `null` allowed is additional `null` checking code. – bansi Jul 30 '13 at 09:58
  • Well that depends on your `business constraints` if your FR requires the value to not nullable, then you have to enforce it with a rule 'NOT NULL' and if not then leave it be. – Mark Jul 30 '13 at 10:01

2 Answers2

2

A simple hint: If you "end up" with many fields being NULL in a table, this is probably the sign that you should split your table in two, using a JOIN operation to retrieve data when needed...


Concerning NULL vs "" remember few things:

  • NULL is the standard SQL way to say "non existent data"
  • NULL is usable both for text and non-text columns. "" is for text-only
  • aggregate functions like COUNT() will ignore NULL values but not ""
  • Column having UNIQUE index allow several rows having a NULL value. But not several rows having "" as value
Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125
2

Start will null values and see how it goes. I think it's a simple enough procedure to update where is null to "".

This question is very similar and has a great answer arguing between null and "". MySQL, better to insert NULL or empty string?

Community
  • 1
  • 1
Alec.
  • 5,371
  • 5
  • 34
  • 69