1,443 views

Consider the following relation:
R (A B C) A primary key with 100 tuples.
S (E F G) E primary key with 50 tuples.
T (AE D) AE primary key with 80 tuples.
U (D G H) H primary key with 10 tuples.
The maximum number of possible records in the result of  _______.

### 4 Comments

@Sanket. If no attributes are common, then natural join doesnt degenerate to cross product.

See this from Korth:

1. Select all the tuples such that attributes are in common. If no attributes in common, no tuple is selected.

2. Project the table such that attributes projected is union of atributes.

@Sushant i think it does degenerate into cross product

if no common attribute it would never evaluate a false hene all will be selected

A cartesian product of two tables will be returned.This is because when we perform any JOIN operation on two tables a cartesian product of those tables is performed and then based on any select condition in WHERE clause the resultant rows are returned.But here as there are no common columns the process stops after cartesian product.

## 3 Answers

R NATURAL JOIN S returns max 5000 rows (As they do not have any Common attribute)

(R NATURAL JOIN S) NATURAL JOIN T returns max 80 Rows

((R NATURAL JOIN S) NATURAL JOIN T) NATURAL JOIN U returns 800 rows.

### 2 Comments

Explain the 2nd and 3rd result
In the third step how could there be cross product as D is still the common attribute.

IN R (ABC) and S (EFG)

tables are not referring or referred to each other, no common attributes

100*50=5000 tuples

Now, as we move further

R Join S Join T, here we have primary key A of R, E of S, and AE of T we see we have something in common.

5000 and 80 we get 80

Now, as we move further

{R Join S Join T} Join U

NOTE: Natural join lets you combine the relationships associated with a foreign key.

so U (D G HH primary key, obviously D and G attributes are referring to the table so they got something in Common

80 and 10 gives 10

Answer is 10

by

after R join S we have all 5000 different combination of A E in our new table say 1

now 1 join T will give 80 different combination  present in T, how – as A E is key in T  which will be compared with all possible combination of AE in best case our all 80 will match and will give 80 tuples , now name the result relation as 2

now key point for max tuples - for max tuples always think of duplicate values of common attribute in the relation in which our common attribute is not key .

here is not key attribute in our both tables (2 and U ) so we can duplicates its value in any of the table for max number of tuple, now your aptitude will come in handy (think on your own now if possible)

2 join U = we have 80 tuples in 2 for maximum match i’m assuming all the G values are same (say 0) and also in U all G values are 0.when our 2’s G is compare with U’s G .

1st tuple of 2 matches with all of U because both have G as 0 and give u 10 tuples

for every 80 tuples there will be 10 tuples in join so resultant table will have 800 tuples.

1 vote
1 answer
1
312 views
0 votes
0 answers
2
418 views
0 votes
0 answers
3
0 votes
1 answer
4