127 views
2 2 votes

Let $R$ and $S$ be union-compatible relations.

Which expression computes $R\cap S$ using only union and set difference?

  1. $(R\cup S)-((R-S)\cup(S-R))$
     
  2. $(R\cup S)-(R-S)$
     
  3. $(R-S)\cup(S-R)$
     
  4. $(R\cup S)-(R\cap S)$

1 Answer

1 1 vote

Start with $R\cup S$.

This contains every tuple appearing in either relation.

Now, $R-S$ contains tuples appearing only in $R$, while $S-R$ contains tuples appearing only in $S$.

Therefore, $(R-S)\cup(S-R)$ contains all tuples belonging exclusively to one of the two relations.

Remove these from the union $:$

$(R\cup S)-((R-S)\cup(S-R))$.

Only tuples appearing in both relations remain.

$\therefore (R\cup S)-((R-S)\cup(S-R))=R\cap S$

Why the others fail:

B does not isolate the intersection. It retains all of $S$.

C gives the symmetric difference, meaning tuples present in exactly one relation.

D already uses $\cap$, so it does not express intersection using only the requested operators.

Hence, the correct answer is A.

Answer:
Position:
Show:

Related questions

2 2 votes
2 2 answers
218
218 views
GO Classes asked Sep 21
218 views
Consider the relations:$\mathrm{Users(username, name, email, password, address)}$and$\mathrm{FriendsWith(username, username2, sincewhen)}$.A friendship tuple indicates th...
2 2 votes
1 1 answer
123
123 views
GO Classes asked Sep 21
123 views
Consider the relations:$\mathrm{STUDENT(name,regno,gpa,level,dept)}$$\mathrm{COURSE(cno,cname,dept)}$$\mathrm{TAKE(regno,cno)}$Using only the basic relational algebra ope...
2 2 votes
1 1 answer
119
119 views
GO Classes asked Sep 21
119 views
Consider $R(a,b)$ and $S(c,d)$.Which relational algebra expression is equivalent to:SELECT a, d FROM R, S WHERE R.a 10 AND R.b = S.c;Use only the basic operators.$\pi_{a...
2 2 votes
1 1 answer
136
136 views
GO Classes asked Sep 21
136 views
Consider $\text{parts(pno, pname, price)}$.Which relational algebra expression returns exactly the names of all parts whose price is greater than $\$200$?$\pi_{\text{pnam...