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

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.

-
My guess is that someone down-voted as you have not provided your thought or what you have tried on the problem. This information helps the MSE Community to better provide guidance to help your learning. Regards. –  Amzoti Jan 26 '13 at 18:20
@Amzoti I've tried to solve by my own but I got stuck in the part I have to performe the union. –  Zignd Jan 26 '13 at 18:26

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)\}$.

-
in order to performe the subtraction you have to use the difference set theory –  Zignd Jan 26 '13 at 18:19
@Zignd Yep. That is correct –  Rustyn Jan 26 '13 at 18:21
I got this R-S: 4 2 3, 1 2 6 and S-R: 2 5 4, if I'm right, so the union is the the 3 sets of numbers? –  Zignd Jan 26 '13 at 18:44
@Zignd That's correct.I'll write in the answer anyway. –  Git Gud Jan 26 '13 at 18:49