in Databases edited by
8,625 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\}$
in Databases edited by
8.6k views

4 Comments

Should the variable t not bounded to a relation as well ? If it is not bounded to a relation then shouldn't t yield infinite no. of tupples in A,B and D. From what I have read the notation followed is { t | R(t) ^ <set of conditions> } .
1
1

Someone please explain how to read Queries 1, 2 and 3. Are they from TRC or DRC and how to interpret them in some English language!

1
1
Does not help at all !!!
2
2
edited by
Any expression whose result uses “constants / values”that do not appear in the instances of any of the database relations.     

or in Simple words

the expression which results in finite no of output is considered as Safe expression and which expression can give infinite output is unsafe.
1
1

6 Answers

45 votes
45 votes
Best answer

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

4 Comments

1 flag:
✌ Low quality (PreyumKr)
"A" also has $\displaystyle \neg s$. It shouldn't be safe as well.

I mean that too contains too many tuples.
0
0
Can you please post source again. Its not working anymore
0
0

"A" also has ¬s. It shouldn't be safe as well.

I mean that too contains too many tuples.

I think as it contains “There exists”  so even just one out of domain tuple will work. 

and hence option C is more stronger.

0
0
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 vote
1 vote
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