1. Understanding of the connection: The connection is also called the θ connection, and the connection between R and relationship S is a new connection from the Cartesian product of the two relationships by selecting a tuple that satisfies a certain condition between the attributes. This condition is θ (comparison operator, such as >, <, =).
2. Natural connection: is a special equivalent connection, compares the same group of attributes in two relationships, and removes the duplicate attribute columns in the result, leaving only tuples of the same component in the attribute group.
3. Left connection: On the basis of a natural connection, add a tuple on the left table that does not contain tuples (rows) that are included in the natural connection.
4. Right connection: On the basis of a natural connection, add a tuple on the right table that does not contain tuples (rows) that are contained in a natural connection.
5. Outer connection: Left JOIN + Right connection
Here is an example to illustrate the above connection:
Relationship R
Relationship S
| B |
C |
D |
| 4 |
6 |
8 |
| 5 |
6 |
7 |
| 4 |
6 |
2 |
| 6 |
8 |
5 |
The Cartesian product of R and S is
| R.a |
R.b |
R.c |
s.b |
S.c |
S.d |
| 2 |
4 |
6 |
4 |
6 |
8 |
| 2 |
4 |
6 |
5 |
6 |
7 |
| 2 |
4 |
6 |
4 |
6 |
2 |
| 2 |
4 |
6 |
6 |
8 |
5 |
| 3 |
5 |
7 |
4 |
6 |
8 |
| 3 |
5 |
7 |
5 |
6 |
7 |
| 3 |
5 |
7 |
4 |
6 |
2 |
| 3 |
5 |
7 |
6 |
8 |
5 |
| 4 |
6 |
8 |
4 |
6 |
8 |
| 4 |
6 |
8 |
5 |
6 |
7 |
| 4 |
6 |
8 |
4 |
6 |
2 |
| 4 |
6 |
8 |
6 |
8 |
5 |
The relationship R and the common attribute group in the relationship s are B and C, find the tuple of B and C equivalent in Cartesian product, remove the duplicate attribute value, get the following
Natural Connection:
| A |
B |
C |
D |
| 2 |
4 |
6 |
8 |
| 2 |
4 |
6 |
2 |
| 4 |
6 |
8 |
5 |
R and S's
left Connection: In the control relationship R, tuples 3, 7, 5 are not included in the natural connection, and the tuple is added on the basis of the natural connection, and there are no columns for the attributes to fill null values.
| A |
B |
C |
D |
| 2 |
4 |
6 |
8 |
| 2 |
4 |
6 |
2 |
| 4 |
6 |
8 |
5 |
| 3 |
7 |
5 |
Null |
R and S's
Right Connection: In the control relationship s, tuples 5, 6, 7 are not included in the natural connection, and the tuple is added on the basis of the natural connection
| A |
B |
C |
D |
| 2 |
4 |
6 |
8 |
| 2 |
4 |
6 |
2 |
| 4 |
6 |
8 |
5 |
| Null |
5 |
6 |
7 |
R and S's
External Connection(r⋈s): Left JOIN + Right connection
| A |
B |
C |
D |
| 2 |
4 |
6 |
8 |
| 2 |
4 |
6 |
2 |
| 4 |
6 |
8 |
5 |
| 3 |
5 |
7 |
Null |
| Null |
5 |
6 |
7 |
Note: R (⋈) S, who is in front of who in the rear