in Databases edited by
4,945 views
35 votes

Which of the rational 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
4.9k 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

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
Does not help at all !!!
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

Subscribe to GO Classes for GATE CSE 2022

5 Answers

38 votes
 
Best answer

Answer: C.

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

Reference: http://nptel.ac.in/courses/IIT-MADRAS/Intro_to_Database_Systems_Design/pdf/3.1_Tuple_Relational_Calculus.pdf

edited by

14 Comments

it is unsafe because of infinite cardinality or inability to show all output ??
m not getting meaning of safe expression.
please explain
2
Safe expressions will give you definite number of tuples.
15
edited by
Can anyone give example of unsafe expression in any context / schema which does not involve negation to yield infinite tuples? I am searching for one such. Is this even possible? @Arjun sir?
0

Consider a relational schema R1 and generally it can take infinite values if domains of attributes aren't restricted.So for any finite instances of relation {t∣¬(tR1)}  will generate instance with infinite tuples so it is unsafe.

eg. R1(Roll Number, Marks) and consider domain of Roll number +ve integers. restriction on marks doesn't matter.

consider a instance of R1

R1
Roll Number Marks
                 1       22
                  2        78

now this {t∣¬(tR1)} will generate all possible value that can be in roll number and Marks exclusing (1,22) and (2,78). That will be infinite so this query is unsafe.

15
Generally, the tuple variable which we see in the TRC query $\{t|..\}$, this tuple variable points to all possible tuples in the universe.

Now, when you say $\{t| t \in R\}$ where R is any relation, then we have bounded the number of tuples, the tuple variable t can refer and it will be always in the domain of R and not outside it, so it will refer to finite tuples.

When we say $\{t| \lnot(t\in R)\}$, means all tuples not in relation R, and there can be many tuples which are not R or not in R, and hence infinite result set and hence an unsafe query.
23
In Option A, B And D,

Nowhere Range for tuple variable ' t ' is mentioned

So t[A] it may points to tuple in any relation who has attribute named "A"

?? is it safe
0
in option A, B and D

t[A] should be equal to our tuple ===> so those are safe

 Option A:- {t∣∃u∈R1(t[A]=u[A])∧¬∃s∈R2(t[A]=s[A])} ===> you can take any tuple, but it should to equal to u[A] which is in our R1.
2
Got it ,

Somewhere we are restricting it !!

So query in A return any TUPLE in universe if There exists tuple in our relation R1 such that they agree on attribute A...considering first condition only
0
@Shaik

Is the equivalent SQL for (A)

Select *

From R1

Where R1.A not in (Select R2.A from R2)?
4
@minipanda

as per my knowledge, yes
1
Sir, In option B, if the table R1 does not contain "x" in attribute A ,then what ever the tuple we take for t it satisfies ,causing indefinite number of tuples as result. Can you please tell me why it is a safe query then?
0
great
0
"A" also has $\displaystyle \neg s$. It shouldn't be safe as well.

I mean that too contains too many tuples.
0
Can you please post source again. Its not working anymore
0
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
0 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.
0 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

 

–3 votes
both a) and c) should be true....can someone plz explain the correct answer

2 Comments

A) A is not unsafe, because we have intersection with R1, so at max we can get all tuples from R1. There is no such restriction in C. So A is not answer
!
22
Thanks.
0
Answer:

Related questions