in Others edited by
1,628 views
1 vote
1 vote

Given two tables $R1(x,y)$ and $R2(y,z)$ with $50$ and $30$ number of tuples respectively. Find maximum number of tuples in the output of natural join between tables $R1$ and $R2$ i.e. $R1 * R2$? ($*$- Natural Join)

  1. $30$
  2. $20$
  3. $50$
  4. $1500$
in Others edited by
1.6k views

4 Comments

@Satbir

Please check this question

$30$ or $1500$ according to you?

0
0

The example you shared has already mentioned the keys in it which makes us to follow the integrity constraints..but here it is not mentioned anything.
for e.g:
X Y      Y Z

a 2        2 z

b 2        2  y

c 2

d  2
                        in this case the ans. should  be 4*2=8  and if even if x and z not mentioned as keys should we not assume it to be, to make the ans for maximum case?

correct me if I am wrong!

0
0

3 Answers

2 votes
2 votes

$\underline{\textbf{Answer:}\Rightarrow}\;1500$

$\underline{\textbf{Explanation:}\Rightarrow}$

$\textbf{Natural Join:}$ In this, the two join attributes must have the common $\mathbf{attribute}$ in both the relations.

$\textbf{Example:}$ In worst case if all the values of the common attribute are same, then total tuples would be $\mathbf{=|m| \times |n|} = 30 \times 50 = 1500$.

$\enclose{circle}{\color{blue}{\mathbf{R_1}}}$
$\color{green}{\mathbf X}$ $\color{green}{\mathbf Y}$
1 CS
2 CS
$\vdots$ $\vdots$
$\vdots$ $\vdots$
47 CS
48 CS
49 CS
$\color{red}{50}$ CS

 

$\enclose{circle}{\color{blue}{\mathbf{R_2}}}$
$\color{green}{\mathbf Z}$ $\color{green}{\mathbf Y}$
Jeet CS
Sunny CS
$\vdots$ $\vdots$
   
$\vdots$ $\vdots$
Anil CS
Gurupreet CS
$\color{red}{30}$ CS

 

$\color{blue}{\mathrm{\enclose{circle}{R_1 \times R_2}}}$
$\color{green}{\mathbf X}$ $\color{green}{\mathbf Y}$ $\color{green}{\mathbf Z}$
1 CS Jeet
2 CS Sunny
3 CS Anil
$\vdots$ $\vdots$ $\vdots$
$\vdots$ $\vdots$ $\vdots$
$\vdots$ $\vdots$ $\vdots$
$\color{magenta}{\enclose{circle}{\mathbf{\underline{\large{1500}}-\small{tuples}}}}$ CS $\dots$

 

$\therefore$ Maximum number of tuples in the output of Natural joing between relation $\mathbf{R_1}$ and $\mathbf{R_2}=\color{magenta}{\enclose{circle}{\mathbf{\underline{\large{1500}}-\small{tuples}}}}$.

edited by
by

4 Comments

Ok sir, I am checking it once.
0
0

Yes, finally it has to be $\mathbf{1500}$ only.

Because if all the values of the common attribute are the same, then each tuple of relation $1$ will match with each other tuple of relation $2$.

So total would be $30\times 50 = 1500$

@Sanjay Sharma

Sir, you are right!

0
0

@Sanjay Sharma

Sir, I have updated my answer now.

0
0
0 votes
0 votes

Answer is 1500

because they are asking maximum

also, note: they have not told is distinct, we can take y values same

let say y values are alpha

then

for R1(x,y) => 50 y alpha values

for R2(y,z) => 30 y alpha values

50 x 30 = 1500 y alpha values

our final natural join relation has x , y and z attributes with 1500 tuples where y values are alpha with same or distinct values of x and z it doesn't matter.

 

 

0 votes
0 votes
1500 is the correct answer.

Consider the following case:

I am representing the database table with relation having ordered pairs.

$R1(A,B)=\{(1,a),(2,a),(3,a)……..(49,a),(50,a)\}$

$R2(B,C)=\{(a,51),(a,52),(a,53)…….(a,78),(a,79),(a,80)\}$

Here the natural join of R1 and R2 will have 1500 rows.

This is because every row of R1 is paired with all the 30 rows of R2.

Related questions