Functions in the relational context

From: Tegiri Nenashi <>
Date: Thu, 6 Mar 2008 12:14:53 -0800 (PST)
Message-ID: <>

Many people from both side of the fence suggested that functional programming is a promising idea that can embrace both paradigms. Here is why I don't think so. Consider the earlier cute exercise:

On Mar 6, 10:55 am, Tegiri Nenashi <> wrote:
> What function the following query
> SELECT x FROM sine WHEN y=0.5
> represent?

We have a relation Sine(x,y), which in SQL looks like this

table Sine (

    x number;
    y number;

One can go ahead and start inserting the values into it, until he realizes that this relation is infinite, so it is better be something else than a table. To simplify the discussion, however, I'll continue to pretend that it is a table (that is relation with finite number of tuples).

Now, consider the query

SELECT y FROM sine WHEN x=pi/4

Without any index on the Sine table, the execution has to scan all the values and filter only those that satisfy the predicate. We'd better have some index to make a quick execution:

create unique index sin on Sine(x);

With this index in place the execution is just a unique index scan, then the retrieval of the matching tuple from the table. Likewise, if we have

SELECT x FROM sine WHEN y=1/2

then we'd better have an index

create index arcsin on Sine(y);

Unlike the previous case it is no longer a unique.

Now does it coincidental, that I named the indexes "sin" and "arcsin", implying that there is perhaps some similarity to the functions sin(), and arcsin()? (The latter being multivalued function, of course). Not at all, the only difference is in implementation:

This idea IMO is a vehicle to extending relations to the infinite case. We can't scan infinite relations in principle, but can join them by the means of the indexes -- that is the functions. Received on Thu Mar 06 2008 - 21:14:53 CET

Original text of this message