![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm new to relational theory, having read a C.J. Date's book but I worry that I may have picked up mistaken impression about the relational theory and thus want to validate whether my understanding is accurate or not. Prior to reading the book, I've always had understood that anything we ... We can see how much relational algebra/calculus can help us optimize any kind of queries by transforming the expression. |
|
But... I don't see any means within the relational algebra that provides a way of evaluating multiple tuples in one go. Considering that a relation is essentially a collection of propositions conforming to a given predicate, it seems necessary to evaluate each tuples to determine whether they should participate in the join or not, satisfy the restrict condition and other things. For a lack of better terms, there is no "sieve" we can employ to evaluate a set of tuples in one go. Is the preceding paragraph accurate? |
#3
| |||
| |||
|
|
I'm new to relational theory, having read a C.J. Date's book but I worry that I may have picked up mistaken impression about the relational theory and thus want to validate whether my understanding is accurate or not. Prior to reading the book, I've always had understood that anything we did in realm of relational algebra (or calculus) would be set-oriented and to lesser extent sames applies to the SQL implementation, at least in the theory (as not all vendors necessarily are consistent in the implementation). Given that any kind of update operation is logically all at once, I was quite concerned with the manners of updating itself. Given two relvars, r and s, containing some numbers of attributes, sharing a common attribute (or in more general parlance, s relvar contains a foreign key to relvar r's candidate key), and we wish to evalulate an expression upon the relvar r and s. Assume the evaluate will include restrict, project and join, though we need not restrict to only those three operators. Relational algebra, like ordinary algebra, can be employed in help us re-formulate the expression into a even simpler expression, with the net result that we can reduce the numbers of tuples to be evaluated as we process the expression. This can be done by examining the operators' properties such as joins having the commutative property and thus choosing the smaller relvar and evaluate its tuples against the bigger relvar's tuples. So far, so good. We can see how much relational algebra/calculus can help us optimize any kind of queries by transforming the expression. But... I don't see any means within the relational algebra that provides a way of evaluating multiple tuples in one go. Considering that a relation is essentially a collection of propositions conforming to a given predicate, it seems necessary to evaluate each tuples to determine whether they should participate in the join or not, satisfy the restrict condition and other things. For a lack of better terms, there is no "sieve" we can employ to evaluate a set of tuples in one go. Is the preceding paragraph accurate? TIA. |
#4
| |||
| |||
|
|
This is not really the case. All these transformations are ad-hock. If you try proving, say, "pushing selection through projection" you would get bogged in set notation with awkward attribute indexing, and even if succeed actually proving it, it would hardly result in any insight. |
|
It is too vague. Algebras, in general, don't care about the structure of their elements; relational algebra, in particular, doesn't refer to tuples. |
#5
| |||
| |||
|
|
What you appear to be looking for is a physical structure not a logical one, which in SQL one would build with the "CREATE INDEX" statement. |
#6
| |||
| |||
|
|
It is too vague. Algebras, in general, don't care about the structure of their elements; relational algebra, in particular, doesn't refer to tuples. ... |
#7
| |||
| |||
|
|
Relational algebra, like ordinary algebra, can be employed in help us re-formulate the expression into a even simpler expression... But... I don't see any means within the relational algebra that provides a way of evaluating multiple tuples in one go. |
#8
| |||
| |||
|
|
The theory allows the query to be reformulated without changing its meaning, but it cannot help estimate the cost of executing one or the other. A simpler expression may in fact cost more to evaluate. |
|
The change was triggered in part at least by the work of Ken J McDonell on the MUSBUS benchmarking tools, who was able to point out the glaring differences in actual behaviour of the RDBMS he benchmarked. |
#9
| |||||
| |||||
|
|
I suppose it's true that we can transform an expression into anything else and could conceivably add as many zeros for additive/subtractive operations or ones for multiplication/division operations and still have logically equivalent expressions, but such expansion would hardly be interesting in absence of further transformation. |
|
Even so, wouldn't it be fair to say that in order to optimize any given query upon relation, we would want to find the most simple (or maybe it's accurate to say 'concise') expression that is computationally simple to execute compared to other but equivalent expressions? |
|
However, could I ask you to explain the statement that tuples aren't referred at all in relational algebra? |
|
Back to the r and s example, if I were to join them based on an attribute x, I would have to look at all possible values in attribute x of the relvar r then go to s and look up each tuples in relvar s and verify whether its attribute x has the same value and thus 'select' the tuple into the resultant output. I've just described an iterative manner of evaluating what tuples may participate in a join and that's precisely concerns me; was that actually necessary or does there exist an operator to process them in bulk? |
|
Or maybe to attempt an analogy, when we multiply two numbers, we need not add each number to itself as many times as specified by other operand. It's valid but not the only way to determine the product; we certainly can determine product by recalling the product from multiplication table and even for an arbitrarily large operands, use the same algorithm to quickly arrive at a product.. Does such concept exist for operating upon relations in like manner? |
#10
| |||
| |||
|
|
Tegiri Nenashi wrote: ... It is too vague. Algebras, in general, don't care about the structure of their elements; relational algebra, in particular, doesn't refer to tuples. ... It might be clearer to say that while the algebra's ops don't refer to tuples, the sets involved certainly do contain tuples and as far as I know, there are no relational ops that can be defined without reference to tuples. |
![]() |
| Thread Tools | |
| Display Modes | |
| |