The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+18 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\}$


asked in Databases by Veteran (68.9k points)
edited by | 1.2k views
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> } .

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 Answers

+21 votes
Best answer
Answer: C

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

answered by Veteran (35.9k points)
selected by
it is unsafe because of infinite cardinality or inability to show all output ??
m not getting meaning of safe expression.
please explain
Safe expressions will give you definite number of tuples.
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?

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

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.

–3 votes
both a) and c) should be true....can someone plz explain the correct answer
answered by Active (1.6k points)
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

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

32,694 questions
39,293 answers
36,702 users