IN ORDER TO IMPLEMENT A SET OF RULES / TUTORIALOUTLET DOT COM IN ORDER TOIMPLEMENTASETOFRULES/TUTORIALOUTLET.COM | Page 30
PRODUCT.
Special database operations:
SELECT (not the same as SQL SELECT), PROJECT, and JOIN.
Relational SELECT
SELECT is used to obtain a subset of the tuples of a relation that
satisfy a select
condition.
For example, find all employees born after 1st Jan 1950:
SELECTdob '01/JAN/1950'(employee) Relational PROJECT
The PROJECT operation is used to select a subset of the attributes of
a relation by
specifying the names of the required attributes.
For example, to get a list of all employees surnames and employee
numbers:
PROJECTsurname,empno(employee) SELECT and PROJECT
SELECT and PROJECT can be combined together. For example, to
get a list of
employee numbers for employees in department number 1: Figure :
Mapping select and project Set Operations - semantics
Consider two relations R and S. UNION of R and S
the union of two relations is a relation that includes all the tuples that
are either in
R or in S or in both R and S. Duplicate tuples are eliminated.
INTERSECTION of R and S
the intersection of R and S is a relation that includes all tuples that are
both in R
and S.
DIFFERENCE of R and S
the difference of R and S is the relation that contains all the tuples that
are in R
but that are not in S. SET Operations - requirements
For set operations to function correctly the relations R and S must be
union compatible.
Two relations are union compatible if
they have the same number of attributes
the domain of each attribute in column order is the same in both R
and S. UNION Example Figure : UNION INTERSECTION Example