Re: The Relational Model & Queries That Naturally Return Duplicate Rows

From: Erwin <>
Date: Sun, 10 Oct 2010 02:35:44 -0700 (PDT)
Message-ID: <>

On 10 okt, 04:56, "Joe Thurbon" <> wrote:
> In the context of recent discussion on the ttm mailing list regarding  
> ORDER BY, it's not clear to me that correct answer is indeed obvious. (In  
> fact, given my track record on cdt, I'm not sure that I am thinking of the  
> correct answer).
> With that caveat in mind, given that, with the OP's database, the query
> presents the user with something that is not a relation, it seems strange  
> to require that
> should. (Apart from that projection is a relational operator, and order by  
> isn't, but that seems to me at least to be slightly subtle).
> Cheers,
> Joe-
> - Tekst uit oorspronkelijk bericht weergeven -

"slightly subtle" ??????

You mean as in "that difference could equally well not exist at all" ?????

In functional style, "SELECT FIRST_NAME from USERS order by FIRST_NAME" is something like ORDER_BY(SELECT(USERS,{FIRST_NAME})), and "SELECT FIRST_NAME from USERS" is just SELECT(USERS, {FIRST_NAME}). From that, it should be indisputably clear that the type of both expressions are different.

The former returns something which conveys order, and thus cannot be a relation, whereas the latter, insofar as we understand SELECT to mean "relational projection", returns a relation, which does not convey order, and cannot possibly contain duplicate tuples.

If one wants SELECT to mean something different than relational projection, then I refer to "Logic and Databases", chapter 12. There, "bag algebra" is investigated (and its inferiority to relational algebra exposed). Received on Sun Oct 10 2010 - 11:35:44 CEST

Original text of this message