Database Reference
In-Depth Information
RELATION A
RELATION B
X
12
13
Y
25
28
S
34
38
45
T
56
99
84
RELATION C
X
12
12
12
13
13
13
Y
25
25
25
28
28
28
S
34
38
45
34
38
45
T
56
99
84
56
99
84
Figure 8-14
PRODUCT operation.
Join
Features and function
Operates on two relations that have common columns.
Connects data across two relations based on values in common columns.
Types of join operations: natural join, theta join, outer join.
The result is a single relation containing rows and columns as indicated
below for a natural join of relations A and B with a common column with
name c:
Take the product of A and B
The resulting relation will have two columns for c
Eliminate all rows from the product except those rows where the value for
column c in one relation is the same the value for column c in the other
relation
Apply project operation to eliminate one of the two common c columns from
the result relation
Example
Refer to Figure 8-15 for the discussion of this operation. Note the two relations
PATIENT and BILLING.
Data request List the billing data for all discharged patients. Call the result rela-
tion DISCHRGPATIENT.
Relational algebra solution
DISCHRGPATIENT :
=
JOIN ( PATIENT, BILLING)
Note the syntax for the operation in relational algebra and the keyword JOIN
indicating the join operation. Note the steps and also the rows and columns
in the final result. The data about patient discharges is in the PATIENT rela-
tion. The BILLING relation contains data about patient billing. We need to
Search WWH ::




Custom Search