Relational-Calculus

Question 1

Let R and S be relational schemes such that R={a,b,c} and S={c}. Now consider the following queries on the database:

I. πR-S(r)-πR-S(πR-S(r)×s-πR-S,S(r))
II. {t|t∈ πR-S(r) ∧ ∀u ∈ s(∃v ∈ r(u = v[s] ∧ t = v[R - S]))}
III. {t|t∈ πR-S(r) ∧ ∀v ∈ r(∃u ∈ s(u = v[s] ∧ t = v[R - S]))}  
IV. Select R.a, R.b
    from R, S 
    where R.c = S.c

Which of the above queries are equivalent?

A
I and II
B
I and III
C
II and IV
D
III and IV
Question 1 Explanation: 
R={a,b,c}
S={c}
I. πR-S(r)-πR-S(πR-S(r)×s-πR-S,S(r))

It looks like Division operator. Since a division operator in E(A,B)/ P(B) will be equal to

Now replacing A=R-S P=r
B=S
E=r
we will get,

equivalent to I
∴ It is equivalent to division operator.
⇒ r(R-S,S)/r(S)

This logical statement means that
① Select t(R-S) from r such that
② for all tuples U in S,
③ there exists a tuple V in r, such that
④ U=V[S] & t=V[R-S]
A(x,y) & B(y)
A/B = {(x) | ∃(x,y)∈A(y)∈B}
which means that A/B contains all x tuples, such that for every tuple in B, there is an xy tuple in A.
So, this is just equivalent to I.

This logical statement means that
① Select t(R-S) from r such that
② for all tuples V in r,
③ there exists a tuple U in r, such that
④ U=V[S] & t=V[R-S]
⇒ Select (R-S) values from r, where the S value is in (r/r), which will be true only if S in r is a foreign key referring to S is r.
IV. Select R.a, R.b
From R, S
Where R.c = S.c
This selects (a,b) from all tuples from r which has an equivalent value in S.
Question 2

Which of the following tuple relational calculus expression(s) is/are equivalent to ∀t ∈ r(P(t))?

    I. ¬∃t ∈ r(P(t))
    II. ∃t ∉ r(P(t))
    III. ¬∃t ∈ r(¬P(t))
    IV. ∃t ∉ r(¬P(t))
A
I only
B
II only
C
III only
D
III and IV only
Question 2 Explanation: 
Demorgan law:
∀xP(x) ≡ ∼∃x(∼P(x))
∼∀x(∼P(x)) ≡ ∃x(P(x))
Given: ∀t ∈ r(P(t))------ (1)
As per Demorgan law
(1) ⇒ ∼∃t ∈ r(∼P(t))
which is option (III).
Question 3

Consider the relation employee(name, sex, supervisorName) with name as the key. supervisorName gives the name of the supervisor of the employee under consideration. What does the following Tuple Relational Calculus query produce?

{e.name|employee(e)∧}
     (∀x)[¬employee(x) ∨ x.supervisorName ≠ e.name ∨ x.sex = "male"]}
A
Names of employees with a male supervisor.
B
Names of employees with no immediate male subordinates.
C
Names of employees with no immediate female subordinates.
D
Names of employees with a female supervisor.
Question 3 Explanation: 
The given Tuple Relational calculus produce names of employees with no immediate female subordinates.
There are 3 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access