Re: more algebra

From: <compdb_at_hotmail.com>
Date: Sat, 10 Apr 2010 21:49:46 -0700 (PDT)
Message-ID: <e04aa1ca-bfa0-4409-b0b7-fff9b935bf85_at_j21g2000yqh.googlegroups.com>


On Apr 6, 5:05 pm, paul c <toledobythe..._at_oohay.ac> wrote:

> ( r GROUP ( { N } AS n ) ) = ( EXTEND r ADD ( RELATION { TUPLE { N
> } AS n ) { K, n }
> will be 'true' iff r satisfies the key constraint.

If we are precise it's a bit more complicated: ( r GROUP ( { n1, ... } AS n ) ) =
  ( EXTEND r ADD RELATION { TUPLE { n1 AS n1, ... } } AS n ) { k1, ..., n }

> I admit the above is pretty ugly but underneath it's pretty simple.

Maybe, if you can find natural language to make it clear that this captures the idea of key constraint.

You don't need to use COUNT or GROUP/nesting. (Ironically the latter, like the former, requires an extension to the original algebra.) "A k-subtuple can't appear with a second n-subtuple." Using calculus (with named arguments):
  FALSE =
    EXISTS k1, ..., n1, ..., _n1, ... :

        r(k1 as k1, ..., n1 as n1, ...)
      AND r(k1 as k1, ..., _n1 as n1, ...)
      AND n1 NOT= _n1 AND ....

Using algebra (with parallel structure to above):   DUM =

    ( ( r JOIN (r RENAME { n1 TO _n1, ...}))    RESTRICT { n1 NOT= _n1, ...}
    ){ALL BUT}
> But as we know, sql is not very rigourous [...]
> So I think the simple user interface is a big trap.

I don't understand this.

By the way it is important to have a keyword for keys. Although a non-keyword expression can be evaluated as a constraint there is in general no way to for a dbms to tell that a given constraint implies a key constraint. And it needs to know this for important optimizations (of other than just relational expressions).

Although I sympathize with you I suggest that it is hopeless to choose the form of your specification on the basis of hoping to circumvent incompetent programming. COUNT has a precise & simple definition, why not use it? Yes, competent designers and implementers use math. Yes, most designers and implementers work willy-nilly. This is true for all programming.

philip Received on Sun Apr 11 2010 - 06:49:46 CEST

Original text of this message