In relational algebra, what would be the result of $(R-S)\cup (S-R)?$

435 Views Asked by At

Suppose relation $R(A,B,C)$ has the following tuples:

$X\;\;\;\; Y\;\;\;Z$

$1\;\;\;\;\; 2\;\;\;\;\; 3$

$4\;\;\;\;\; 2\;\;\;\;\; 3$

$4\;\;\;\;\; 5\;\;\;\;\; 6$

$2\;\;\;\;\; 5\;\;\;\;\; 3$

$1\;\;\;\;\; 2\;\;\;\;\; 6$

and relation $S(A,B,C)$ has the following tuples:

$X\;\;\;\; Y\;\;\; Z$

$2\;\;\;\;\; 5\;\;\;\;\; 3$

$2\;\;\;\;\; 5\;\;\;\;\; 4$

$4\;\;\;\;\; 5\;\;\;\;\; 6$

$1\;\;\;\;\; 2\;\;\;\;\; 3$

How do I compute $(R - S) \cup (S - R)$? What would be the result?
Thanks.

1

There are 1 best solutions below

4
On BEST ANSWER

We have $R=\{(1,2,3), (4,2,3), (4,5,6), (2,5,3), (1,2,6)\}$ and $S=\{(2,5,3), (2,5,4), (4,5,6), (1,2,3)\}$.

Can you now compute $R-S$ and $S-R$ as elementary operations on sets?

It's useful to notice that $R-S=R-(R\cap S)$ and $S-R=S-(R\cap S)$.

We have $R\cap S=\{(1,2,3), (4,5,6), (2,5,3)\}$.

It follows $R-S=\{(4,2,3), (1,2,6)\}$ and $S-R=\{(2,5,4)\}$, therefore $R\cup S=\{(4,2,3), (1,2,6), (2,5,4)\}$.