edited by
8,531 views
46 votes
46 votes

Which of the following relational calculus expression is not safe?

  1. $\left\{t \mid \exists u \in R_1\left(t[A] = u[A]\right) \land \neg \exists s \in R_2 \left(t[A] = s[A]\right)\right\}$
  2. $\left\{ t \mid \forall u \in R_1\left(u[A]="x" \Rightarrow \exists s \in R_2\left(t[A] = s[A] \land s[A] = u[A]\right)\right) \right\} $
  3. $\left\{t \mid \neg (t \in R_1)\right\} $
  4. $\left\{t \mid \exists u \in R_1\left(t[A]=u[A]\right) \land \exists s \in R_2 \left(t[A] = s[A]\right)\right\}$
edited by

6 Answers

Best answer
45 votes
45 votes

Answer: C.

It returns tuples not belonging to R1 (which is infinitely many). So, it is not safe.

Reference: https://people.cs.pitt.edu/~chang/156/10calculus.html

edited by
2 votes
2 votes
Well it’s obvious that the answer is (C).

But can anyone verify my analysis of other Options?

Option (A) : Prints values which are in column A of R1,but not in Column A of R2.

Option (B) : It will print ‘x’ every time it is in column A of R1 and in atleast one time in column A of R2. Oh wait ,bcoz it is a Set ,’x’ will be printed only once!

Option (D) : Prints values if which are in column A
of both relations R1 & R2
2 votes
2 votes

{t∣¬(t∈R1)}

If we run this query the tuples we get does not belong to the instances of relation R1, so according to definition this expression is unsafe.

ANSWER: C

 

1 votes
1 votes
The relations that result in infinite number of tuples are considered to be unsafe operations. And so safe operations give us finite number of tuples. But here option (C) gives us infinite number of tuples as it results in tuples which are not belonging to R and since they are infinite.
Answer:

Related questions

128 votes
128 votes
6 answers
3
7 votes
7 votes
3 answers
4
go_editor asked Feb 8, 2018
1,986 views
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.Write an SQL query to list the regno of examinees who have a s...