Natural join of three relations worked example

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-502 DBMS November 2022 solved question paper

RGPV CS-502 (GS) | November 2022 | Q2(b) | 7 marks

Question (restated): Evaluate R ⋈ S and (R ⋈ S) ⋈ T for the supplied relations R(a,b), S(b,c), T(c,d).

Answer

Given data

a b
0 1
4 5
8 9
b c
1 2
5 2
5 6
5 10
13 10
c d
2 3
6 7
10 11
10 3

A natural join matches tuples on all attributes having the same name and retains each common attribute only once. R and S share b. The row with b=1 matches one S row; b=5 matches three rows; b=9 has no match. The S row with b=13 has no R match.

First join R ⋈ S

a b c
0 1 2
4 5 2
4 5 6
4 5 10

The intermediate result shares c with T. Each c=2 row matches d=3; c=6 matches d=7; c=10 matches both d=11 and d=3. Thus the last intermediate row generates two result rows.

Final result

a b c d
0 1 2 3
4 5 2 3
4 5 6 7
4 5 10 11
4 5 10 3
SELECT * FROM R NATURAL JOIN S NATURAL JOIN T;

The first join contains four tuples and the final join contains five. Unmatched rows are discarded because this is an inner natural join, not an outer join.

Further reading: Silberschatz, Korth and Sudarshan, Database System Concepts.

← RGPV CS-502 DBMS November 2022 solved question paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion