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

From: Paul <>
Date: 14 Feb 2003 04:07:36 -0800
Message-ID: <>

"Bob Badour" <> wrote in message news:<g8W2a.1405$>...
> 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

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":

The TOP 5 query still returns an unordered set in theory: although you get the top 5 salaries it wouldn't matter in what order those 5 were returned. In fact you can do these TOP-style queries using COUNT and subqueries I think, which is just about domain ordering. So really this ORDER BY is syntactic shorthand, which also deals with problems like ties etc.

The "SELECT * FROM emp ORDER BY salary" is different because it implies an order to the *relation* not just the domains of its attributes.

I suppose that in theory a query language could do without an ORDER BY and have any ordering done in the client application. 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.

Paul. Received on Fri Feb 14 2003 - 13:07:36 CET

Original text of this message