| As long as you can represent your query with predicate logic and not violate set theory (or other relational tenants), it's perfectly "relational". It's important to note that folks have figured out how to extend Codd's original relational algebra with stuff like aggregation. As the OP mentioned, "Relational" doesn't mean "What Codd wrote in a single paper back in 1969". It has continued to evolve, both with Codd's direct involvement and from successors like Date, Darwin, and Pascal. Codd wasn't an all-seeing, all-knowing data-management demi-god - but his general theory of relational database management and the core tenants are still super awesome. Extensions to it, as long as they don't violate the RM, are just as valid as Codd's original work. That means #1 is totally relational (as an aside, you don't need ORDER BY or LIMIT for it either). Indeed, relational algebra supports aggregations (http://en.wikipedia.org/wiki/Relational_algebra#Aggregation). It's important to separate the query language from core RDBMS theory, as the two are orthogonal. Codd suggested Relational Algebra as a reference language but never intended for it to be the only way to communicate with a RDBMS. See CJ Date's excellent discussion on ORDER(BY):
http://books.google.com/books?id=WuZGD5tBfMwC&lpg=PA163&... EDIT:
It even seems folks have figured out how to make "LIMIT" relational operator:
http://stackoverflow.com/questions/10229535/relational-algeb... I have not read the paper, so I cannot discuss the validity of the approach. |
I would love to see it. Yes, you can do it in SQL, but I'd say it's not easy at all without ORDER BY and LIMIT or windowing functions and I don't know if you can do it in Tutorial D. For the reference, #1 is:
Show the blog post with the largest number of comments. If more than one exist, pick the latest.
The schema is:
See CJ Date's excellent discussion on ORDER(BY)I read it and the book as well, but I wouldn't call it excellent. What I read there is a reluctant admission of failure to incorporate an important operation to his query model. I see no attempt to analyze why it doesn't work or adapt the query model to make ORDER a regular operation.