Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Relational algebra
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== ''θ''-join and equijoin === Consider tables ''Car'' and ''Boat'' which list models of cars and boats and their respective prices. Suppose a customer wants to buy a car and a boat, but she does not want to spend more money for the boat than for the car. The ''θ''-join (⋈<sub>''θ''</sub>) on the predicate ''CarPrice'' ≥ ''BoatPrice'' produces the flattened pairs of rows which satisfy the predicate. When using a condition where the attributes are equal, for example Price, then the condition may be specified as ''Price''=''Price'' or alternatively (''Price'') itself. {{col-begin|width=auto; margin:0.5em auto}} {{col-break}} {| class="wikitable" |+ ''Car'' |- ! CarModel !! CarPrice |- | CarA || 20,000 |- | CarB || 30,000 |- | CarC || 50,000 |} {{col-break|gap=2em}} {| class="wikitable" |+ ''Boat'' |- ! BoatModel !! BoatPrice |- | Boat1 || 10,000 |- | Boat2 || 40,000 |- | Boat3 || 60,000 |} {{col-break|gap=2em}} {| class="wikitable" |+ <math>{ Car \bowtie Boat \atop \scriptstyle CarPrice \geq BoatPrice }</math> |- ! CarModel !! CarPrice !! BoatModel !! BoatPrice |- | CarA || 20,000 || Boat1 || 10,000 |- | CarB || 30,000 || Boat1 || 10,000 |- | CarC || 50,000 || Boat1 || 10,000 |- | CarC || 50,000 || Boat2 || 40,000 |} {{col-end}} In order to combine tuples from two relations where the combination condition is not simply the equality of shared attributes it is convenient to have a more general form of join operator, which is the ''θ''-join (or theta-join). The ''θ''-join is a binary operator that is written as <math>{R\ \bowtie\ S \atop a\ \theta\ b}</math> or <math>{R\ \bowtie\ S \atop a\ \theta\ v}</math> where ''a'' and ''b'' are attribute names, ''θ'' is a binary [[relational operator]] in the set {{math|1 = {<, ≤, =, ≠, >, ≥}}}, ''υ'' is a value constant, and ''R'' and ''S'' are relations. The result of this operation consists of all combinations of tuples in ''R'' and ''S'' that satisfy ''θ''. The result of the ''θ''-join is defined only if the headers of ''S'' and ''R'' are disjoint, that is, do not contain a common attribute. The simulation of this operation in the fundamental operations is therefore as follows: : ''R'' ⋈<sub>''θ''</sub> ''S'' = ''σ<sub>θ</sub>''(''R'' × ''S'') In case the operator ''θ'' is the equality operator (=) then this join is also called an '''equijoin'''. Note, however, that a computer language that supports the natural join and selection operators does not need ''θ''-join as well, as this can be achieved by selection from the result of a natural join (which degenerates to Cartesian product when there are no shared attributes). In SQL implementations, joining on a predicate is usually called an ''inner join'', and the ''on'' keyword allows one to specify the predicate used to filter the rows. It is important to note: forming the flattened Cartesian product then filtering the rows is conceptually correct, but an implementation would use more sophisticated data structures to speed up the join query.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)