Re: Extending my question. Was: The relational model and relational algebra - why did SQL become the industry standard?
Date: Wed, 19 Feb 2003 06:38:18 GMT
Message-ID: <3E5325DD.8040802_at_earthlink.net>
Mikito Harakiri wrote:
> Please, write down a query that transforms
>
> Num
> ---
> 2
> 5
>
> into
>
> Seq# Num
> ---- ---
> 1 2
> 2 2
> 1 5
> 2 5
> 3 5
> 4 5
> 5 5
>
> in pure relational syntax. Now, the same, please, without
> explode/recursion operator.
Assuming the existance of a table (real or virtual) that contains the integer values (at least from 1 through 5), then it is possible and fairly simple. The hypothetical table is: INTEGERS, and contains a single column, N, of type INTEGER. The basic table Mikito postulated can be COUNTS, containing a single column, C, of type INTEGER.
In SQL:
SELECT I.N AS "Seq#", C.C AS "Num"
FROM INTEGERS AS I, COUNTS AS C WHERE I.N BETWEEN 1 AND C.C ORDER BY "Num", "Seq#";
Hugh Darwen (writing as Andrew Warden) wrote about the "Act of Chivalry" for a TRDBMS to provide a table like INTEGERS in Chapter 21 "A Constant Friend" of 'Relational Database Writings: 1985-1989' by C J Date.
-- Jonathan Leffler #include <disclaimer.h> Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com Guardian of DBD::Informix 1.04.PC1 -- http://dbi.perl.org/Received on Wed Feb 19 2003 - 07:38:18 CET