2.6k views

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\}$

edited | 2.6k views
+1
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!

+2
Does not help at all !!!
+1
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.

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

by Boss (33.9k points)
edited
+1
it is unsafe because of infinite cardinality or inability to show all output ??
m not getting meaning of safe expression.
+9
Safe expressions will give you definite number of tuples.
0
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?
+14

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.

+13
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.
0
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
+1
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.
0
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
+3
@Shaik

Is the equivalent SQL for (A)

Select *

From R1

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

as per my knowledge, yes
0
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
both a) and c) should be true....can someone plz explain the correct answer
by Active (1k points)
+20
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
!
0
Thanks.