The Gateway to Computer Science Excellence

+26 votes

Which of the rational calculus expression is not safe?

- $\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\}$
- $\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\} $
- $\left\{t \mid \neg (t \in R_1)\right\} $
- $\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\}$

+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> } .

+33 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

+1

it is unsafe because of infinite cardinality or inability to show all output ??

m not getting meaning of safe expression.

please explain

m not getting meaning of safe expression.

please explain

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*∣¬(*t*∈*R*1)} 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

Roll Number | Marks |
---|---|

1 | 22 |

2 | 78 |

now this {*t*∣¬(*t*∈*R*1)} 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.

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

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.

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

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

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?

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.4k
- Admissions 595
- Exam Queries 573
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,737 questions

57,365 answers

198,494 comments

105,260 users