Re: Counting propositions
Date: Tue, 22 Jun 2004 00:08:06 +0100
Message-ID: <_SJBc.18359$NK4.3212222_at_stones.force9.net>
x wrote:
>> If columns a & b combined are a candidate key, we want to say
>> something like: "select count(a,b) from R" but I don't think this
>> is legal syntax in SQL. Maybe it should be? Are there reasons why
>> not?
> > So we really want to count just the candidate keys, not the > propositions ?
Counting the candidate keys is equivalent to counting the propositions. I just think that extending the count syntax to multiple columns feels a neater way of generalising it. count(*) seems a bit of an anomaly because it kind of operates on a relation instead of the data within the relation.
>> If you think of "*" as a wildcard that expands to all the columns,
>> "select count(*) from R" would be literally like "select
>> count(a,b,c) from R" which might be useful if you couldn't
>> instantly remember what the candidate keys were and couldn't be
>> bothered to look them up. Similar to the "select * from R" syntax.
> > But if you only intended "select count(distinct a,b,c)" instead of > "select count(*)", if the candidate key change you are in trouble.
Certainly, I'm just thinking of its ad-hoc interactive uses in a similar way to how "select *" is used.
> There is a need for select count(*) (other than as a replacement for > "select count(distinct a,b,c)" ) ?
I don't think so. Just as there's not really a need for "select *".
>> I know that it has been said COUNT is redundant because it can be
>> done with SUM. But counting is a much more fundamental concept
>> logically. Any domain can be counted. SUM requires a domain with
>> all the arithmetic structure to define addition. So COUNT is purer:
>> it can exist independently of domains whereas SUM requires
>> cooperation from the domains.
> > Well, not any domain can be counted and for counting a domain, you > need the natural numbers anyway.
In a database context every domain can be counted surely, since it has finite storage space? Though what I really meant was that in any relation, the number of distinct values in a column can be counted irrespective of the domain.
Paul. Received on Tue Jun 22 2004 - 01:08:06 CEST