This equivalence is helpful because evaluation of the

Info iconThis preview shows pages 2–4. Sign up to view the full content.

View Full Document Right Arrow Icon
This equivalence is helpful because evaluation of the right hand side avoids producing many output tuples which are anyway going to be removed from the result. Thus the right hand side expression can be evaluated more efFciently than the left hand side expression. 13.2 ±or each of the following pairs of expressions, give instances of relations that show the expressions are not equivalent. a. P A ( R S ) and P A ( R ) P A ( S ). b. H B < 4 ( A G max ( B ) as B ( R )) and A G max ( B ) as B ( H B < 4 ( R )). c. In the preceding expressions, if both occurrences of max were re- placed by min would the expressions be equivalent? d. ( R a S ) a T and R a ( S a T ) In other words, the natural left outer join is not associative. (Hint: Assume that the schemas of the three relations are R ( a , b 1) , S ( a , b 2), and T ( a , b 3), respectively.) e. H h ( E 1 a E 2 ) and E 1 a H h ( E 2 ), where h uses only attributes from E 2 . Answer: a. R = { (1 , 2) } , S = { (1 , 3) } The result of the left hand side expression is { (1) } , whereas the result of the right hand side expression is empty.
Background image of page 2

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Exercises 3 b. R = { (1 , 2) , (1 , 5) } The left hand side expression has an empty result, whereas the right hand side one has the result { (1 , 2) } . c. Yes, on replacing the max by the min , the expressions will become equivalent. Any tuple that the selection in the rhs eliminates would not pass the selection on the lhs if it were the minimum value, and would be eliminated anyway if it were not the minimum value. d. R = { (1 , 2) } , S = { (2 , 3) } , T = { (1 , 4) } . The left hand expression gives { (1 , 2 , null , 4) } whereas the the right hand expression gives { (1 , 2 , 3 , null ) } . e. Let R be of the schema ( A , B ) and S of ( A , C ). Let R = { (1 , 2) } , S = { (2 , 3) } and let H be the expression C = 1. The left side expres- sion’s result is empty, whereas the right side expression results in { (1 , 2 , null ) } . 13.3 SQL allows relations with duplicates (Chapter 3). a. DeFne versions of the basic relational-algebra operations h , P , × , a , , , and that work on relations with duplicates, in a way consistent with SQL. b. Check which of the equivalence rules 1 through 7.b hold for the multiset version of the relational-algebra deFned in part a. Answer: a. We deFne the multiset versions of the relational-algebra operators here. Given multiset relations r 1 and r 2 , i. h Let there be c 1 copies of tuple t 1 in r 1 . If t 1 satisFes the selection h H , then there are c 1 copies of t 1 in h H ( r 1 ), otherwise there are none. ii. P ±or each copy of tuple t 1 in r 1 , there is a copy of tuple P A ( t 1 ) in P A ( r 1 ), where P A ( t 1 ) denotes the projection of the single tuple t 1 . iii.
Background image of page 3
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page2 / 10

This equivalence is helpful because evaluation of the right...

This preview shows document pages 2 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online