in Databases
3,656 views
4 votes
4 votes
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
in Databases
by
3.7k views

4 Comments

Type of join not mentioned. But how many tuples would result from a natural join? Can it be calculated from the above data?
0
0
Is     answer  5000
0
0
I think , some foreign key constraints may be given ????
0
0

4 Answers

4 votes
4 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 

selected by

4 Comments

In this question, R and S has attribute "A" common but max no of tuples possible is not 10000*5000, hence I asked to correct it, if I misunderstood your 2nd statement then please clarify further.
0
0
That is because further conditions are also applied in the relations.
1
1
Now I understood properly :)
0
0
7 votes
7 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.

1 comment

reshown by
yes,true 36000100 is the answer.
1
1
1 vote
1 vote

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. 

0 votes
0 votes
ans is 1001. am is crt

Related questions

2 votes
2 votes
1 answer
4