Re: Examples of SQL anomalies?

From: Marshall <marshall.spight_at_gmail.com>
Date: Mon, 30 Jun 2008 23:34:46 -0700 (PDT)
Message-ID: <23f5e158-3136-4bb9-8ef8-380c89f5cef2_at_w34g2000prm.googlegroups.com>


On Jun 30, 6:03 pm, paul c <toledoby..._at_ac.ooyah> wrote:
> Bob Badour wrote:
> > Marshall wrote:
>
>
> >> [I meant to say this in my other post, but]
>
> >> Brian gets it exactly right here.
>
> >> Marshall
>
> > Well, except that SQL adds the additional anomaly that
> > count(*) != sum(1)
>
> > ie. SQL can count zero rows with count but not with sum.
>
> I was hoping you two would pipe up about this because as usual, it is
> completely unclear whether CELKO is trying to answer the OP's question
> or whether he is trying to justify SQL's myriad behaviours. (Not
> claiming this is deliberate, though I do have my suspicions!)

'fraid I can't help with that! :-)

> On the matter of 'common sense', I've learned not to trust it, at least
> as a first principle, as it often turns out to be a cover phrase meaning
> 'that's what I thought in the first place' and thus varies dramatically
> depending on the person, the moment and the lingo in play. For sure,
> bringing up intricate arbitrary logics like Johnston's is phony in this
> case. Elementary logic such as described, say, by Bertrand Russell (who
> had far fewer axes to grind than Celko and Johnston), in which the empty
> set has zero members, happens to agree with Brian S's common sense, so
> everybody except of course for the technocratic apologists and
> opportunists ought to be content that SQL once again paints itself into
> a corner.

Yeah, I considered quibbling with the phrase "common sense" but decided against. Brian didn't say that common sense was what *caused* that to be the answer; he just described that answer as being (consistent with) common sense. Which I'd call exactly right.

(I figure I give Brian enough grief when he says stuff I disagree with, I ought to be able to give credit when it's due.)

> [...]
> There are a few tricks in FOL that can trip anybody up, but far fewer
> than the rather amateur legalese the SQL standard contains.

Agreed.

Although to take it one further, one doesn't even need to appeal to FOL to justify; one can appeal to basic arithmetic.

Or one can look to the functional programming world, and see what they do with folds over empty lists.

Or one can even appeal to an imperative programmer's inherently procedural bias, and ask him how he'd most simply program it. He'd say:

count = 0;
for each item
  count = count + 1
end for

And what does that evaluate to if there are no items?

Marshall Received on Tue Jul 01 2008 - 08:34:46 CEST

Original text of this message