Re: Examples of SQL anomalies?
Date: Wed, 2 Jul 2008 09:16:33 -0700 (PDT)
On Jul 2, 6:26 am, Bob Badour <bbad..._at_pei.sympatico.ca> wrote:
> If one expects a bill and the total is 0, that's just as useful to alert
> one that the bill has not yet arrived as a NULL would be.
I would have to disagree here a little. The problem arises from trying to overload the semantics of a single number. It's something junior programmers do a lot.
On the one hand, we have the question of Has the bill arrived? On the other hand, we have the question of How much do we owe? These are two different questions, even if there is some relationship between the two.
If we try to put multiple things into a single value, it's generally a bad idea without a discipline of some kind. The best approach is either 1) don't do that or 2) use a union type. There is also 3) partition the range of values.
Splitting the question up into different question (1) is the best approach here. If SQL had union types, we could do that. NULL is a poor-man's union type, with difficult-to-predict limited semantics.
An example of 3) would be a function that returns a natural number on success or a negative code on failure.
Marshall Received on Wed Jul 02 2008 - 11:16:33 CDT