Skip to content
Official PYQ · 2007

GATE CS 2007 Q60 — Tuple Calculus and SQL

Explain with AI

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"]}\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[\neg employee\left(x \right) \vee x.supervisorName \neq e.name \vee x.sex = ``male" \right]\right\}

Choose one option
View worked solution

Answer: C

To understand what the Tuple Relational Calculus (TRC) query produces, let us analyze the logical expression inside the universal quantifier (orallxorall x):

¬employee(x)∨x.supervisorName≠e.name∨x.sex="male"\neg employee(x) \vee x.supervisorName \neq e.name \vee x.sex = \text{"male"}

Using the logical equivalence ¬A∨¬B∨C≡(A∧B)  ⟹  C\neg A \vee \neg B \vee C \equiv (A \wedge B) \implies C, we can rewrite the expression as:

(employee(x)∧x.supervisorName=e.name)  ⟹  x.sex="male"(employee(x) \wedge x.supervisorName = e.name) \implies x.sex = \text{"male"}

Now, substituting this back into the original query, we get:

{e.name∣employee(e)∧(∀x)[(employee(x)∧x.supervisorName=e.name)  ⟹  x.sex="male"]}\{e.name \mid employee(e) \wedge (\forall x) [ (employee(x) \wedge x.supervisorName = e.name) \implies x.sex = \text{"male"} ]\}

Let's break down the meaning of this rewritten query:

  • employee(e)employee(e): We are selecting an employee ee.
  • employee(x)∧x.supervisorName=e.nameemployee(x) \wedge x.supervisorName = e.name: This represents any employee xx who is an immediate subordinate of ee (since ee is their supervisor).
  • (∀x)[⋯  ⟹  x.sex="male"](\forall x) [\dots \implies x.sex = \text{"male"}]: For all such employees xx, if xx is an immediate subordinate of ee, then xx must be male.

If all immediate subordinates of ee must be male, it logically means that employee ee has no immediate female subordinates (vacuously true if ee has no subordinates at all).

Therefore, the query retrieves the names of employees with no immediate female subordinates.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions