Set Difference
If R1 and R2 are two union compatible relations or relations then result of R3 =R1- R2 is the relation that have only those tuples that are in R1 but not in R2.
Incase, R3 will have tuples such that R3 = {t | R1 ∋ t ∧ t∉R2}.
Example:
R1
X
|
Y
|
A1
|
B1
|
A7
|
B7
|
A2
|
B2
|
A4
|
B4
|
|
|
R2
A
|
B
|
A1
|
B1
|
A2
|
B2
|
A3
|
B3
|
A4
|
B4
|
R1-R2 =
|
|
R1-R2 =
R2-R1=
Note: -1) Difference operation is not commutative, i.e.,
R1 - R2 ≠ R2 - R1
2) Difference operation is not associative, i. e.,
R1 - (R2 - R3) ≠ (R1 - R2) - R3