Re: Counting propositions

From: Paul <>
Date: Fri, 18 Jun 2004 18:15:20 +0100
Message-ID: <gqFAc.16567$>

x wrote:

>>But, for every table, "select count(*)" provides useful information -
>>provided you understand what the table means.

> I just showed you that you don't need to count the propositions for counting
> the employees. :-)
> You only need to count the Emp_IDs ... :-)

count(*) seems like a bit of a clumsy syntax. Suppose we have a relation R with columns a,b,c. (assume proper relation i.e. no duplicates allowed)

If a is a candidate key, count(*) is unnecessary, we can just use "select count(a) from R"

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?

Currently you would have to do "select count(*) from (select b,c from R)" if you wanted to know how many distinct (b,c) pairs there were. (I'm assuming an implicit "distinct" in my hypothetical relational SQL-like language here).

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.

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.

Paul. Received on Fri Jun 18 2004 - 19:15:20 CEST

Original text of this message