# 132 for each of the following pairs of expressions

• Notes
• 10

This preview shows page 2 - 5 out of 10 pages.

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.

Subscribe to view the full document.

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.
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 .

Subscribe to view the full document.

• Spring '13
• Dr.Khansari
• right hand

{[ snackBarMessage ]}

###### "Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern