3,806 views
1 1 vote

How the following two expressions are equal?

The LHS will remove duplicates but RHS will not.Please explain

3 Answers

Best answer
5 5 votes

Both the expressions are equal.

The LHS is not natural join but conditional join, which is cross product of r and s and then projection of those tuples in the cross product that satisfy the given condition.

Consider r(A, B, C) and S(C, D)

r :

A B C
1 2 3
2 1 2

and s :

C D
3 4
1 4

and let the condition c be r.B < s.C 

So, r $\bowtie$c s will be :

r.A r.B r.C s.C s.D
1 2 3 3 4
2 1 2 3 4

An important point to note here is that unlike in natural join, conditional join will contain all the columns of cross product.

And r X s will be :

r.A r.B r.C s.A s.B
1 2 3 3 4
1 2 3 1 4
2 1 2 3 4
2 1 2 1 4

And after applying the condition r.B < s.C, we get

r.A r.B r.C s.C s.D
1 2 3 3 4
2 1 2 3 4
• selected by
0 0 votes

The LHS is a theta Join not a natural join, so it won't remove duplicates and the RHS is a condition enforced on Cartesian Product. 

In Conditional Join  AKA Theta Join, while performing cartesian product only the condition is evaluated.
In the RHS, first the Cartesian Product is evaluated and then the condition is enforced.

Both result in same output.

Position:
Show:

Related questions

2 2 votes
1 answers 1 answer
1.3k
1.3k views
rohitkaushal1 asked Sep 25, 2022
1,329 views
Information about a collection of students is given by the relation studinfo (studid, name, sex). The relation enroll (studld, Courseld) gives which student has enrolled ...
0 0 votes
0 0 answers
895
895 views
gatecrack asked Dec 10, 2018
895 views
1 1 vote
2 2 answers
2.2k
2.2k views
aditi19 asked May 8, 2019
2,154 views
Suppliers(sid, sname, address)Parts(pid, pname, color)Catalog(sid, pid, cost)Find the pids of the most expensive parts supplied by suppliers named Yosemite Sham
5 5 votes
3 3 answers
12.2k
12.2k views
aditi19 asked Apr 11, 2019
12,219 views
Given two relations R1 and R2, where R1 contains N1 tuples, R2 contains N2 tuples, and N2>N1 0, give the minimum and maximum possible sizes (in tuples) for the result rel...