Database Reference
In-Depth Information
ordinates without any supervisory responsibilities. Call the result relation
SUBORDDOCTOR.
Relational algebra solution
SUBORDDOCTOR :
=
SUBDOCTOR — SUPVRDOCTOR
Note the syntax for the operation in relational algebra and the symbol — indi-
cating the difference operation. The difference operation finds only those enti-
ties in the SUBDOCTOR relation but not present in the SUPVRDOCTOR
relation. These are subordinates that do not have any supervisory responsi-
bilities at all. Note the solution shown in Figure 8-13.
Also note that the result will not be same if you reverse the order of the two
relations in the difference operation.
(A—B) is not the same as (B—A). (SUPVRDOCTOR — SUBDOCTOR) rep-
resents the doctors who only have supervisory responsibilities and do not
report to any other doctor at all.
Product
Features and function
•
Operates on two relations.
•
Produces the scalar product between the two relations.
•
By itself, the product operation has no meaning in business functions. But the
product operation is an essential interim operation for the more important join
operation.
•
The result is a single relation containing rows and columns as indicated below:
•
Rows—formed by concatenation each of row of one relation to each row of
the other relation
•
Columns—all the columns of both relations put together
Example
Refer to Figure 8-14 for the discussion of this operation. Note the two relations
A and B.
Data request
Find the product relation C between two relations A and B.
Relational algebra solution
C :
=
A
*
B
Note the syntax for the operation in relational algebra and the symbol
*
indi-
cating the product. Observe how the rows for relation C are formed from the
rows of A and B.
Let us generalize the product operation.
If relation A has
m
columns and
p
rows, and relation B has
n
columns and
q
rows,
then the result relation C will have
(m+n)
columns and
(p
*
q)
rows.
Search WWH ::
Custom Search