Chapter 4 Answer
Chapter 4 Answer
CS 604
March 29 2003
Chapter 4: Relational Algebra and Relational Calculus:
Review Questions:
4.3 Define the five basic relational algebra operations. Define the join,
Intersection, and Division operations in terms of these five basic.
Selection: The selection operation works on a single relation R and defines a
relation that contains only those tuples of R that satisfy the specified
condition {(predicate)
Projection: The projection operation works on single relation R and defines a
relation that contains a vertical subset of R, extracting the value of specified
attributes and eliminating duplicates.
Cartesian product: (R x S) The Cartesian product operation defines a
relation that is the concatenation of every tuples of relation R with every tuple
of relation S.
Union: (R U S) Union of two relations R and S defines a relation that
contains all the tuples of R, or S, or both R and S duplicate tuples being
eliminate. R and S must be union-compatible.
Set difference: (R – S) The set difference operation defines a relation
consisting of the tuples that are in relation R, but not in S. R and S must be
union-compatible.
The 5 fundamental operations in relational algebra perform most of the data
retrieval operations that we are interested in. In addition, there are also:
Join: Join operation combines two relations to form a new relation, is one
of the essential operations in the relational algebra.
Intersection: Produce relation that contains all the tuples in both R and
S. R and S must be union-compatible.
Division operations: Division operation defines a relation over the
attributes C that consist of the set of tuples from R that match the
combination of every tuples in S.
4.4. Discuss the differences between the five joint operations: Theta joint,
Equijoin, natural join, Outher join, and semijoin. Give example to illustrate
your answer?
Theta join: Produce a relation that contains tuples satisfying the predicate F
from the Cartesian product of R and S.
Equijoin: Produces a relation that contains tuples satisfying the predicate F
(which only contains equality comparison) from the Cartesian product of R
and S
Natural join: An equijoin of the two relations R and S over all common
attributes x. One occurrence of each common attribute is eliminated.
Outher join: Joint in which tuples from R that do not have matching values
in the common attributes of S are also included in the result relation.
Semijoin: Produce a relation that contains the tuples of R that participate in
the join of R with S.
EXERCISES
4.8 Describe the relation that would be produces by the following relational algebra
operations:
A. Produce a list of hotelNo for all Room, showing only List all room with a
price greater than 50.
C. List the Hotel names of all Hotels where Hotel.hotelNo = Room with a price
greater than 50.
D. List the Guess of all Booking who have date.To greater equal than 1
January 2002.
E. List complete details of all Hotels where Hotel.hotelNo = Room with a price
greater than 50.
4.9. Provide the equivalent tuple relational calculus and domain relational calculus
expression for each of the relational algebra queries given in Exercise 4.8
4.10 Describe the relations that would be produced by the following tuple relational
calculus expressions: