1

I dodged a heated debate concerning nulls in the database today.

My opinion is that null is an excellent indicator of unspecified values. Everyone else in the team, that has an opinion, thinks zero and empty strings are the way to go.

Are they lazy or am I too strict?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
idstam
  • 2,848
  • 1
  • 21
  • 30

4 Answers4

11

They are lazy and do not understand the basic idea of a null in the database. Nulls are useful and have a purpose. They should neither be avoided nor used inappropriately.

Adam Robinson
  • 182,639
  • 35
  • 285
  • 343
  • 3
    In our databases we have millions of rows of data with billions of nulls. They haven't harmed us yet (over ten years of experience with them), nor, a la Siegfried & Roy, are we worried they will one day rise up and strangle us. – Cyberherbalist Apr 22 '09 at 15:13
3

null means no value while 0 doesn't, if you see a 0 you don't know the meaning, if you see a null you know it is a missing value

I think nulls are much clearer, 0 and '' are confusing since they don't clearly show the intent of the value stored

SQLMenace
  • 132,095
  • 25
  • 206
  • 225
0

Surely if its unspecified then null is a good indicator, zero means something whereas null doesnt. I'm no expert DB though..

Charlie
  • 10,227
  • 10
  • 51
  • 92
0

Despite the extra work that using nulls requires I think there SHOULD be a difference between a non specified field and a field set to empty or 0.

Who else will you be able to say that a user set the value 0 on purpose or if he didn't set the field?

Sergio
  • 8,125
  • 10
  • 46
  • 77