3 ms·
From a theory perspective, SQL has it backwards. The projection operation in relational algebra would come last. It certainly helps with IDE interactions but
by wvenable 16y ago
From a theory perspective, SQL has it backwards. The projection operation in relational algebra would come last. It certainly helps with IDE interactions but it makes sense entirely on its own.
- buro9 16y agoThat's how I saw it too, much closer to set theory and relational algebra. Besides... when I write SQL I write it thus: SELECT * FROM BLAH Then refine to: SELECT * FROM BLAH WHERE FOO Before finally adding: SELECT COL1, COL2 FROM BLAH WHERE FOO Linq matches the way I construct SQL by putting it into the order I logically think of it: FROM BLAH WHERE FOO SELECT COL1, COL2
- olavk 16y agoI may be confused, but according to Wikipedia http://en.wikipedia.org/wiki/Projection_%28relational_algebra%29 http://en.wikipedia.org/wiki/Projection_%28relational_algebr... it seems that in relational algebra notation the attribute names are written before the relation, since the relation is an argument to the projection function. This seem to me to be closer to SQL syntax.
- wvenable 16y agoThe attribute names are written first, but it's like nested function calls: projection(selection(R)). The joins are 'evaluated' first, then selection (where), and then projection. I suspect that SQL was actually designed to match the notational order (but reversing the intent) they still got it wrong: to match the notation, it should be SELECT .. WHERE .. FROM.
- olavk 16y agoInteresting point, but that would apply to function notation in general, not just relational algebra. a(b(c(x))) is "backwards" because the functions are evaluated in the opposite order than they are written. This is a flaw in math and in most programming languages! I suppose stack-based languages have it right, and the OO method chaining syntax in Linq and in e.g. JQuery has it right, since evaluation order is left-to-right.