Imagine we have two tables: R1(A,B,C) and R2(A,M,N) where "u" and "s" denote tuples from each relation respectively.
The output tuple "t" should satisfy the following condition:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(a) SAFE
t[A]=u[A] AND NOT(t[A]=s[A])
This means: the attribute will be present in the output tuple "t" if it is the attribute A from R1, and that same value of A should not appear in R2.
From this analysis, there is no possibility of the relation generating an infinite output.
Thus, option (a) is safe and the correct answer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(b) SAFE
In predicate logic, "for all" (∀) is usually followed by implication (⇒), keeping things simple.
If all u[A] in R1 are "x", then " t " will have that value from R2
If not, the result is empty.
This clearly means the output won’t be infinite, so the query is safe.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(c) UNSAFE
Assume R is a finite set. Then NOT R means we're considering everything not in R, which has no defined boundary. It could include an infinite number of unknown values.
So, as simple as that , the result can be infinite, making it unsafe.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(d) SAFE
Here, the output will include only those values of A that are common to both R1(A)and R2(A).
Basically, it’s like saying, “Give me what’s in both friend circles.”