Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Relational algebra
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Relational algebra
(section)
Add topic