edited by
8,683 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\}$
edited by

6 Answers

1 votes
1 votes

Answer will be $B,C.$

TRC Queries in both Option B, C are Unsafe Queries. 

Definition of “Unsafe TRC Expression”: Any expression whose result uses “constants / values” that do not appear in the instances of any of the database relations.  

Option B:

NOTE that “$x$” is some constant value, in the domain of variable $A.$

Case 1:

If the instance of $R_1$ has at least one tuple where $R_1.A = $ ”$x$” & the instance of $R_2$ also has at least one tuple where $R_2.A = $ ”$x$” then the result of the TRC query will be a table with single column named $A$ and only one row with value “$x$”.

Case 2:

If the instance of $R_1$ has at least one tuple where $R_1.A = $ ”$x$” BUT the instance of $R_2$ also has NO tuple where $R_2.A = $ ”$x$” then the result of the TRC query will be an Empty table with single column named $A$ i.e. Output is Empty.

Case 3:

If the instance of $R_1$ has NO tuple where $R_1.A = $ ”$x$” then every value in the domain of attribute $A$ will satisfy the condition given in the TRC query & hence, will appear in the output. Hence, in this case, we get an infinite number of tuples in the output.

Hence, Query in Option B is Unsafe. 

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

Related questions

128 votes
128 votes
6 answers
3
7 votes
7 votes
3 answers
4
go_editor asked Feb 8, 2018
2,028 views
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.Write an SQL query to list the regno of examinees who have a s...