# Vii if there are c 1 copies of tuple t in r 1 and c 2

• Notes
• 10

This preview shows pages 4–6. Sign up to view the full content.

vii. 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 min ( c 1 , c 2 ) copies of t in r 1 r 2 . b. All the equivalence rules 1 through 7.b of section 13.2.1 hold for the multiset version of the relational-algebra defined in the first part. There exist equivalence rules which hold for the ordinary relational- algebra, but do not hold for the multiset version. For example con- sider the rule :- A B = A B ( A B ) ( B A ) This is clearly valid in plain relational-algebra. Consider a multiset instance in which a tuple t occurs 4 times in A and 3 times in B . t will occur 3 times in the output of the left hand side expression, but 6 times in the output of the right hand side expression. The reason for this rule to not hold in the multiset version is the asymmetry in the semantics of multiset union and intersection. 13.4 Consider the relations r 1 ( A , B , C ), r 2 ( C , D , E ), and r 3 ( E , F ), with primary keys A , C , and E , respectively. Assume that r 1 has 1000 tuples, r 2 has 1500 tuples, and r 3 has 750 tuples. Estimate the size of r 1 a49 r 2 a49 r 3 , and give an efficient strategy for computing the join. Answer: The relation resulting from the join of r 1 , r 2 , and r 3 will be the same no matter which way we join them, due to the associative and com- mutative properties of joins. So we will consider the size based on the strategy of (( r 1 a49 r 2 ) a49 r 3 ). Joining r 1 with r 2 will yield a relation of at most 1000 tuples, since C is a key for r 2 . Likewise, joining that result with r 3 will yield a relation of at most 1000 tuples because E is a key for r 3 . Therefore the final relation will have at most 1000 tuples. An efficient strategy for computing this join would be to create an index on attribute C for relation r 2 and on E for r 3 . Then for each tuple in r 1 , we do the following: a. Use the index for r 2 to look up at most one tuple which matches the C value of r 1 . b. Use the created index on E to look up in r 3 at most one tuple which matches the unique value for E in r 2 . 13.5 Consider the relations r 1 ( A , B , C ), r 2 ( C , D , E ), and r 3 ( E , F ) of Practice Exercise 13.4. Assume that there are no primary keys, except the entire schema. Let V ( C , r 1 ) be 900, V ( C , r 2 ) be 1100, V ( E , r 2 ) be 50, and V ( E , r 3 ) be 100. Assume that r 1 has 1000 tuples, r 2 has 1500 tuples, and r 3 has 750

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

Exercises 5 tuples. Estimate the size of r 1 a49 r 2 a49 r 3 and give an efficient strategy for computing the join. Answer: The estimated size of the relation can be determined by cal- culating the average number of tuples which would be joined with each tuple of the second relation. In this case, for each tuple in r 1 , 1500/ V ( C , r 2 ) = 15/11 tuples (on the average) of r 2 would join with it. The intermedi- ate relation would have 15000/11 tuples. This relation is joined with r 3 to yield a result of approximately 10,227 tuples (15000/11 × 750/100 = 10227). A good strategy should join r 1 and r 2 first, since the intermediate relation is about the same size as r 1 or r 2 . Then r 3 is joined to this result.
This is the end of the preview. Sign up to access the rest of the document.
• Spring '13
• Dr.Khansari
• right hand

{[ snackBarMessage ]}

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