Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is maximum number of tuples in natural join

Tags:

database

Given relations R and S, each has n and m tuples, respectively. After natural join of R and S, what could be the maximum numbers of tuples? I saw one given answer is n*m but I couldn't figure out what is such a case. Please help me understand this scenario.

like image 822
Accordion Avatar asked May 09 '15 22:05

Accordion


People also ask

Can the result of natural join have more than one tuples?

The result of natural join becomes equal to the Cartesian product when there are no common attributes. The given tables have a common attribute, so the result of natural join cannot have more than the number of tuples in larger table. What is the minimum possible number of tuples?

What is the maximum number of tuples in the enroll table?

Since there are only 8 tuples in the Enroll table, the maximum number of tuples in the natural join of Student and Enroll cannot be greater than 8.

How many tuples are there in table s in SQL?

Table R contains 2 tuples, Table S contains 3 tuples, where Result table contains 2*3=6 tuples. Moreover, while performing a natural join, if there were no common attributes between the two relations, Natural join will behave as Cartesian Product.

How many tuples are there in relation R and s?

Which of the following functional dependencies hold for relations R (A, B, C) and S (B, D, E): The relation R contains 200 tuples and the rel ation S contains 100 tuples. What is the maximum number of tuples possible in the natural join of R and S (R natural join S)


2 Answers

I hope, you understood what Natural Join exactly is. You can review here.

If the tables R and S contains common attributes and value of that attribute in each tuple in both tables are same, then the natural join will result n*m tuples as it will return all combinations of tuples.

Consider following two tables

Table R (With attributes A and C)

 A  |  C
----+----
 1  |  2
 3  |  2

Table S (With attributes B and C)

 B  |  C
----+----
 4  |  2
 5  |  2
 6  |  2

Result of natural join R * S (If domain of attribute C in the two tables are same )

 A | B |  C
---+---+----
 1 | 4 |  2
 1 | 5 |  2
 1 | 6 |  2
 3 | 4 |  2
 3 | 5 |  2
 3 | 6 |  2    

You can see both R and S contain the attribute C whose value is 2 in each and every tuple. Table R contains 2 tuples, Table S contains 3 tuples, where Result table contains 2*3=6 tuples.

Hope this will help.

like image 153
Surajeet Bharati Avatar answered Oct 09 '22 00:10

Surajeet Bharati


Writing this post as I could not add to Surajeet's answer

Number of Tuples after a join (R>< S) for relation R(A,B,C) and S(C,D,E) is given by T(R>< S) =

Number of tuples for join

where V(R,C) is distict values of C in relation R and V(S,C) is distict values of C in relation S

in extreme case if there is only 1 distinct value and that value is same (assuming conservation of value sets). Then we get T(R>< S) = T(R) * T(S). Hence n*m.

like image 44
Hemanth Kumar Avatar answered Oct 08 '22 23:10

Hemanth Kumar