# Re: Extending my question. Was: The relational model and relationalalgebra - why did SQL become the industry standard?

Date: Sun, 16 Feb 2003 12:57:38 -0500
Message-ID: <VEQ3a.81\$6O5.14523431_at_mantis.golden.net>

"Paul" <pbrazier_at_cosmos-uk.co.uk> wrote in message news:51d64140.0302140407.11a55b43_at_posting.google.com...
news:<g8W2a.1405\$Ay3.168203281_at_mantis.golden.net>...
> > Some operations on relations require an explicit order: quota query,
min,
> > max etc.
>
> Isn't there two separate issues here?
> 1) order on domains
> 2) order of tuples within a relation

My whole point, Paul, was the relational model disallows implicit order of tuples within relations; however, it does allow operations that rely on an explicit order of tuples within relations. Any explicit order necessarily depends on the possible collating sequences of the values derivable from the attributes in the tuples of the relation.

> The first would be generally desirable (not sure about things like
> image-valued domains though) and is needed for the MIN & MAX aggregate
> operations.
>
> The second isn't really part of relational theory but appears to be
> needed for quota queries (I assume this is things like "SELECT TOP 5 *
> FROM emp ORDER BY salary"). Although thinking about it this ORDER BY
> is really different to the standard "SELECT * FROM emp ORDER BY
> salary":

I disagree. Both ORDER BY clauses explicitly order the tuples of the input relation as required for some operation. One operation results in an unordered set, ie. a relation with the five highest ranking tuples, and the other results in an external physical representation of a relation in a specified order. However, the contribution of the ORDER BY clause is identical in both. (I don't much like the syntax you used for the quota query because it is not at all clear that the order by applies to the TOP operation. How would the user tell the dbms to output the resulting five tuples in ascending alphabetical order by last name?)

> I suppose that in theory a query language could do without an ORDER BY
> and have any ordering done in the client application.

Codd's RM/V2 excludes any such thing when it requires theta-operations like less than, greater than, least greater, greatest lesser etc. Any data management language unable to order data would lack utility for evaluating extrema and for partitioning data, which are fundamentally data management tasks.

> But for physical
> reasons it would be more efficient for the DBMS to choose an
> optimization method that would output the rows in a specified order.

It might and it might not. It depends on the query and any declared constraints to leverage or enforce. Received on Sun Feb 16 2003 - 18:57:38 CET

Original text of this message