Re: Domains as relations

From: Paul <pbrazier_at_cosmos-uk.co.uk>
Date: 10 Oct 2002 04:19:24 -0700
Message-ID: <51d64140.0210100319.179421f8_at_posting.google.com>


hidders_at_hcoss.uia.ac.be (Jan.Hidders) wrote in message news:<3da42c32$1_at_news.uia.ac.be>...
> Constraint databases: A tutorial introduction (2000)
> Jan Van den Bussche
> SIGMOD Record (ACM Special Interest Group on Management of Data)
>
> http://citeseer.nj.nec.com/vandenbussche00constraint.html

Looks interesting, I'll check constraint databases out in more detail.

I've been thinking about expressing aggregates in purely relational language and I'm not sure if it is possible.

For example, consider the set S={0,1,2,3}. I can use this as a domain for a table. In order to have aggregates I need to also define a binary operator on this set. e.g. addition modulo 4. I can define this in a relation with 3 columns i.e. if (a,b,c) is the tuple representing a+b=c I would have (0,1,1), (1,2,3), (2,2,0)... etc. Now since the rows of relations don't have any order, the "plus" operator has to be associatative [a+(b+c)=(a+b)+c] and commutative [a+b=b+a] otherwise it wouldn't be well-defined. Ideally you'd have closure identity and inverses as well so that you have a mathematical group.

So suppose I have a table with tuples (x, 1), (y, 2), (z, 3) where the "first" column is some arbitrary domain just used for the primary key and the other has the set S as the domain. How do I express:

SELECT Sum(secondcolumn) FROM table

in a purely relational form?

Conceptually I need to select two arbitrary tuples and add them together (using joins to the "plus" relation) in an arbitrary order. Then do the same with the result and the third tuple. If I has n tuples I would do this n-1 times.

It's this "arbitrary-ness" that I can't work out. (We're assuming here that there is no order defined on S). Is this a non-issue or do I really need some way of choosing an arbitrary row of a table?

The other issue is requiring a non-fixed number of joins requiring some kind of induction syntax for the query language. But I think this may be a problem just with the query language rather than the underlying relational theory.

Is it possible to define an aggregate in purely relation terms in this way without requiring that the domain has an ordering defined?

Paul. Received on Thu Oct 10 2002 - 13:19:24 CEST

Original text of this message