Professional Documents
Culture Documents
(i) Union
(ii) Difference
(iii) Intersection
(iv) Cartesian Product
Union:-
The union operation of two relations (tables) results in a new relation containing
rows from both relations with duplicates removed. The two relations used in the
union operation must be union compatible i.e. they must have the same number of
columns and corresponding columns in the select statement must come from the
same domain. Union operation is a binary operation which means that it always
operates on two relations. The notation for the union of relations (tables) P and Q is
PᴗQ.
Suppose we have two relations P and Q, then the union of P and Q is R as shown
below: Here relations P and Q are having same degree 2 and they are drawn from
common domain so they are union compatible. The resultant relation R obtained
by taking union of P and Q, contains all the rows from P as well as from Q but the
duplicate rows such as (503, Anand}, {504, Amitabh}, (510, Kapil) occur only once.
Thus duplicacy is removed.
Intersection:-
The Cartesian product of two relations (tables) results in a new relation that
includes concatenation or combination of every tuple (row) of first relation with
every tuple (row) of second relation, In other words, the new relation is created
consisting of all possible combination of the tuples (rows). It is also known as
cross product or cross join. It is not necessary for the relation on which this
operation is to be performed to be union compatible. The Cartesian product is a
binary operation which means that it always operates on two relations. The
notation for the Cartesian product of relations (tables) P and Q is PX Q.
Suppose we are given two relations P and Q and the resultant relation obtained on
performing cartesian product is shown by R (i.e. R = PxQ) The resultant relation R
obtained by calculating the cartesian product of relations P and Q, contains the
possible combination of all the rows of P relation (table) with the rows of the Q relation
(table). The total number of the columns in the resultant relation R is equal to the sum
of a number of columns in relation P and relation Q i.e. (2+2=4). The total number of
rows in the resultant relation (table) R is equal to the product of number of rows in
relation P and relation Q. i.e. (3x2=6).
(2) Special Operators:-
The division operation results in a new relation (table) such that every tuple (row)
appearing in the resultant relation must exist in the dividend relation (i.e. First table) in
combination with the every tuple (row) in divisor relation (second table). It is a binary
operation which operates on two relations. The division is denoted by a symbol "÷".
The notation for the division of two relations P and Q is P+ Q where P is the dividend
relation and the Q is the divisor relation. The division operation is suited to queries that
include the phrase "For all".
Consider another example, in which we take two relations Pand Q.
The resultant relation R obtained by P÷Q in each case when tuples of Q are differentWhen a relation
P is divided by a relation Q (ie P÷ Q) then result is all the tuples that appear the divided relation i.e. P
in combination with divisor relation i.e. Q.In case (1) where Q is having values {n,, n} and P is having
some values that use n, and n in addition to other values. These are {m,n; mn; m.n; mn: mn}. Out of
these values, all except man, is having fixed values of m, where i = 1,4 with n, and n So on dividing P
with Q relation i.e. P÷ Q, it results in {m,, m.}. Similarly in case (ii) where Q is having value {n}. So on
performing P+Q, the answer is {m,, m₂, m₂). It can also be written as
m₁n/n,= m₂; m₂; n/n, = m₂; m₂ n/n, = m₂