132 for each of the following pairs of expressions

Info icon This preview shows pages 2–5. Sign up to view the full content.

View Full Document Right Arrow Icon
13.2 For each of the following pairs of expressions, give instances of relations that show the expressions are not equivalent. a. Pi1 A ( R S ) and Pi1 A ( R ) Pi1 A ( S ). b. H9268 B < 4 ( A G max ( B ) as B ( R )) and A G max ( B ) as B ( H9268 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 a49 S ) a49 T and R a49 ( S a49 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. H9268 H9258 ( E 1 a49 E 2 ) and E 1 a49 H9268 H9258 ( E 2 ), where H9258 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.
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 H9258 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. Define versions of the basic relational-algebra operations H9268 , Pi1 , × , a49 , , , 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 defined in part a. Answer: a. We define the multiset versions of the relational-algebra operators here. Given multiset relations r 1 and r 2 , i. H9268 Let there be c 1 copies of tuple t 1 in r 1 . If t 1 satisfies the selection H9268 H9258 , then there are c 1 copies of t 1 in H9268 H9258 ( r 1 ), otherwise there are none. ii. Pi1 For each copy of tuple t 1 in r 1 , there is a copy of tuple Pi1 A ( t 1 ) in Pi1 A ( r 1 ), where Pi1 A ( t 1 ) denotes the projection of the single tuple t 1 . iii. × If there are c 1 copies of tuple t 1 in r 1 and c 2 copies of tuple t 2 in r 2 , then there are c 1 c 2 copies of the tuple t 1 . t 2 in r 1 × r 2 . iv. a49 The output will be the same as a cross product followed by a selection. v. If there are c 1 copies of tuple t in r 1 and c 2 copies of t in r 2 , then there will be c 1 c 2 copies of t in r 1 r 2 , provided that c 1 c 2 is positive. vi.
Image of page 3
4 Chapter 13 Query Optimization If there are c 1 copies of tuple t in r 1 and c 2 copies of t in r 2 , then there will be c 1 + c 2 copies of t in r 1 r 2 .
Image of page 4

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

View Full Document Right Arrow Icon
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern