retagged by
856 views
10 votes
10 votes
Consider three tables with the following number of tuples in each:

$X$$\left ( a,b,c \right )$ $= 100$   ||   $Y$$\left ( a,d,e \right )$ $= 80$   ||   $Z$$\left ( x,d,f \right )$ $= 90$

Tuples in $X$ and $Y$ with same value of attribute ’$a$’ $= 60$.

Tuples in $Y$ and $Z$ with same value of attribute ’$d$’ $= 70$.

The maximum number of tuples in  ( $X$ left outer join $Y$ )  full outer join $Z$  is ________.
retagged by

2 Answers

Best answer
4 votes
4 votes
A = ( X left outer join Y ): This will have 100 rows, with d = null for 40(= 100 - 60) rows.

A full outer join Z: Here the common values of d in tables A and Z can be between 50 and 60.

1. Minimum value of common values of d between A and Z :

Out of 80 values of d in Y , 20 were not found in A (since A has only 60 non-null values of d).  These 20 can all be the ones that were common between A and T In this case the common
values between  A and Z will be 50.

2. Maximum value of common values of d between A and Z :

Now assume that 20 values of d that were lost, none were common between X and Y. But this is not possible, because Y has 80 tuples and 70 values are common with Z . So at least 10 common values will get lost. Thus max. value of common d’s will b 60.

Now full outer join ( A + Z - common values of d in A and Z ) will be  100 + 90 - 50 . Thus maximum is 140 .
selected by
1 votes
1 votes

What if all the common attributes(where ever they are common) are the same value. I mean here X.a = Y.a, say all the common values have the same value say = "1" then max total tuples will be 60*60 + 40(nulls) = 3640. and applying the same logic to the whole question we get max as 252070 tuples. 

Please look at the tables and corresponding queries. it is a smaller database but obeys the approach and conditions that are mentioned in the question. 

size of X = 10 , Y = 8, Z = 9 ;

common(X, Y) = 6, common(Y,Z) = 7

Result Set X

select * from X ;
 

A B C
1 10 11
1 10 11
1 10 11
1 10 11
1 10 11
1 10 11
2 10 11
3 10 11
4 10 11
5 10 11

Download CSV
10 rows selected.

Result Set Y

select * from Y;

A D E
1 10 11
1 10 11
1 10 11
1 10 11
1 10 11
1 10 11
44 10 11
44 11 11

Download CSV
8 rows selected.

Result Set Z

select * from Z ;
 

P D F
1 10 11
2 10 11
3 10 11
4 10 11
5 10 11
6 10 11
7 10 11
3 11 11
32 234 32

Download CSV
9 rows selected.

Result Set 


select count(*) from X left join Y on X.a = Y.a full outer join Z on Y.d = Z.d ;

COUNT(*)
258

Download CSV

Answer:

Related questions

3 votes
3 votes
3 answers
1
Bikram asked Feb 9, 2017
764 views
A radio is available at $\text{₹} 27780/-$ cash price, or three equal annual installments at $15\%$ per annum under $CI$ compounding annually. Each installment amount, ...
1 votes
1 votes
1 answer
3
Bikram asked Feb 9, 2017
751 views
Out of six coins, four coins are tossed simultaneously.The number of possible outcomes where at most three of the coins turn up as heads is ______.
1 votes
1 votes
1 answer
4
Bikram asked Feb 9, 2017
287 views
In a class of $30$ students, $A$ is ranked eighth from the top. $B$ is five ranks below $A$.$B’s$ rank from the bottom is _____.