The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+1 vote

Suppose you are given relations r(A, B) and s(A, C). Suppose that r has 10000 tuples, and s has 5000 tuples. Suppose attribute r.A has 1001 distinct values, and s.A also has 1001 distinct values. The maximum possible size of the join result is

+2 votes

Best answer

Refering page no. 121 - 123 of http://cs.iit.edu/~cs525/slides/allhandouts.pdf

**CASE 2 **: W = R1 Join R2 when X ∩ Y = A

T(W) = T(R2) * T(R1) / max{ V(R1,A), V(R2,A) }

where V(R1,A) = Max distinct column A tuples in Relation R1

and V(R2,A) = Max distinct Column A tuples in Relation R2

it should be (10000*5000)/1001 = 49950

A | B |

1 | a1 |

1 | a2 |

1 | a3 |

1 | a4 |

1 | a5 |

2 | b1 |

2 | b2 |

2 | b3 |

2 | b4 |

2 | b5 |

A | C |

1 | u |

1 | v |

2 | w |

2 | y |

2 | z |

R1(A,B) Join R2 (A,C) = 10*5/2 = 25 Tuples

0

@Ashish I want to say if there are two relation given for eg. R(A,B) and S(A,C).

here comman attribute is A, but it is not PK of any table. if R has total 10 tuples but only 2 distinct values. and S also has 2 distinct values with 5 total number of tuples.( same case as in your given eg)

Then R natural join with S, will give max 37 tuples. this is what I want to say..ignore my first comment.

here comman attribute is A, but it is not PK of any table. if R has total 10 tuples but only 2 distinct values. and S also has 2 distinct values with 5 total number of tuples.( same case as in your given eg)

Then R natural join with S, will give max 37 tuples. this is what I want to say..ignore my first comment.

0

@ Reena...what you want to say by "Then R natural join with S, will give max 37 tuples"....it is a relational instance, at particular instant of time it is fixed and therefore, it will give value 25 only...

0

If two relation R ans S, with tuples m and n respectively

1) if no attribute is comman then maximum no of tuples in natural join will be "mn".

2) but if any attribute is comman but not the key of any Table then in this case also max tuples will be "mn".

this is what I found,check it

1) if no attribute is comman then maximum no of tuples in natural join will be "mn".

2) but if any attribute is comman but not the key of any Table then in this case also max tuples will be "mn".

this is what I found,check it

0

yes, this is what you are saying is true....but why are you saying that it will make 37 tupples...it is relational instance...there is nothing like minimum or maximum tupples for a relational instance...it will give fixed amount of tupples..

0

I am not taking above instance.

if there are two relation given for eg. R(A,B) and S(A,C)

I only considered the features of that table, not the values of tuples.

0

@Reena ...can u pls elaborate your answer with table (using data from above tables)... (its just because even i solved and found 25 tuples only)

0

see, what I am saying

yes its true for the above table answer is 25. what I actually want to say, read my all comments again!

yes its true for the above table answer is 25. what I actually want to say, read my all comments again!

0

i dint get ur query wrt to above table pls clear that... and ur first comment which said something about 37 tuples

+1

If two relation R ans S, with tuples m and n respectively

1) if no attribute is comman then maximum no of tuples in natural join will be "mn".

2) but if any attribute is comman but not the key of any Table then in this case also max tuples will be "mn".

this is what I found,check it

2nd statement is wrong, if we consider @venkat_sirvisetti 's answer.

Please correct it!

0

@Shyam take an instance and check it by yourself.

If anything wrong in that statement,then let me know!!

If anything wrong in that statement,then let me know!!

+4 votes

Considering natural join property where tuples are joined when the values of the common attributes are equal, the maximum joins wil be in this scenario:

In relation r, there are 1001 distinct values of A. Since total of 10000 tuples in r, we get 8,999 tuples with repeated values of A

Similary in realtion s, there are 1001 distinct values of A. Since total of 5000 tuples in s, we get 3,999 tuples with repeated values of A.

The maximum joins happen when all tuple are repeated with same value.

Hence total maximum joins possbile is (9000*4000) + 1000 = 36001000.

In relation r, there are 1001 distinct values of A. Since total of 10000 tuples in r, we get 8,999 tuples with repeated values of A

Similary in realtion s, there are 1001 distinct values of A. Since total of 5000 tuples in s, we get 3,999 tuples with repeated values of A.

The maximum joins happen when all tuple are repeated with same value.

Hence total maximum joins possbile is (9000*4000) + 1000 = 36001000.

0 votes

Consider this Scenario :

R (A,B) : 10000 rows ( showing Seperate Values Of A and B for a tuple/row)

A Tuples ( a1,a2,.......,a1001, (a1001,........ a1001) 8999 times ) B Tuples ( b1,b2,b3,.........,b10000 )

S (A,C) : 5000 rows ( showing Seperate Values Of A and C for a tuple/row)

A Tuples ( a1,a2,.......,a1001, (a1001,........ a1001) 3999 times ) C Tuples ( c1,c2,c3,.........,c5000 )

Now Making Join Of Both (Natural Join) ( For each tuple of R matching with Each tuple of S on basis of Common Column A)

For a1 : Match Found : 1 ; a2 : Match Found 1 ; ................ ; a1000 : Match Found 1 ; (Inidividual Match **(A)** :1000 )

For a1001 :

Match Found : For R -> A ( row no 1001) : With S -> A (row no 1001)

For R -> A ( row no 1001) : With S -> A (row no 1002)

... So 4000 matches for R -> A ( row no 1001 ) .... Similarly 4000 matches for R -> ( row no 1002) ....

For Others : 8999 a1001's of relation R -> Matches by Duplicate **(B)** : 9000 * 4000 = 36 * 10^6

Total Matches : **(A) + (B)** : 36000000 + 1000 = 36001000. (Answer)

P.S. : Here we are taking as many as duplicates in Relation R and S ; because we need to find maximum number of tuples.

- All categories
- General Aptitude 1.2k
- Engineering Mathematics 4.8k
- Digital Logic 2k
- Programming & DS 3.5k
- Algorithms 3k
- Theory of Computation 3.8k
- Compiler Design 1.5k
- Databases 2.8k
- CO & Architecture 2.5k
- Computer Networks 2.9k
- Non GATE 941
- Others 1.2k
- Admissions 334
- Exam Queries 410
- Tier 1 Placement Questions 17
- Job Queries 52
- Projects 8

34,234 questions

40,919 answers

116,193 comments

39,834 users