24,168 views
96 votes
96 votes

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?

$\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\}$

  1. Names of employees with a male supervisor.
  2. Names of employees with no immediate male subordinates.
  3. Names of employees with no immediate female subordinates.
  4. Names of employees with a female supervisor.

6 Answers

Best answer
227 votes
227 votes
OR ($\vee$) is commutative and associative, therefore i can rewrite given query as:

$\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[\neg employee\left(x \right) \vee x.sex = ``male" \vee x.supervisorName \neq e.name \right]\right\}$

$\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[\neg (employee\left(x \right) \wedge x.sex \neq ``male") \vee x.supervisorName \neq e.name \right]\right\}$

$\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[ (employee\left(x \right) \wedge x.sex \neq ``male") \Rightarrow x.supervisorName \neq e.name \right]\right\}$

$\left\{e.name \mid employee(e) \wedge \left(\forall x\right)\left[ (employee\left(x \right) \wedge x.sex =``female") \Rightarrow x.supervisorName \neq e.name \right]\right\}$

It is clear now they are saying something about female employees, This query does not say anything about male employees. Therefore Option A and B are out of consideration.

This query retrieves those $e.name$ who satisfies this condition:

$\forall x [(employee(x)\wedge x.sex="female")\Rightarrow x.supervisorName\neq e.name]$
 
Means retrieves those e.name, who is not a supervisor of any female employees.
i.e it retrieves name of employees with no female subordinate.
(here "immediate" is obvious, as we are checking first level supervisor.)

Hence, option C.
edited by
51 votes
51 votes

{e.name∣employee(e)∧(∀x)[¬employee(x)∨x.supervisorName≠e.name∨x.sex=‘‘male"]}            ...(1)

By Using De-morgan's law

We can write expression  ∀x(P(X)) as NOT ∃x(NOT P(X)).

Using this concept, we rewrite the conditon (1) as given in question above

{e.name∣employee(e)∧ NOT(∃x)[employee(x) ^ NOT x.supervisorName≠e.name ^  NOT x.sex=‘‘male"]}            ...(2)

Considering only 2 genders are represented in the database as either male or female we can again rewrite expression (2) as

{e.name∣employee(e)∧ NOT(∃x)[employee(x) ^  x.supervisorName = e.name ^   x.sex=‘‘female"]}            ...(3)

Now it is easier to read the expression above.

It Says, for a tuple of employee, there must not be a case that this employee being considered is supervisor of some female employee. That means it selects all those employee who do not supervise any female employee hence do no have any immediate female sub-ordinate.

Hence, Ans (C)

38 votes
38 votes
Query is selecting e such that e is an employee and for all x, either x is not an employee or x's supervisor's name is not e.name or x is male.

So, this is equivalent to saying, select all employees who don't have an immediate female subordinate. (Assuming there is no transgender). (C) option.
Answer:

Related questions

21.3k
views
13 answers
98 votes
Aravind asked Oct 4, 2014
21,273 views
Information about a collection of students is given by the relation $\text{studInfo(}\underline{\text{studId}},\text{ name, sex)}$. The relation $\text{enroll(}{\text{stu...
9.8k
views
5 answers
27 votes
Kathleen asked Sep 21, 2014
9,843 views
Consider the following schedules involving two transactions. Which one of the following statements is TRUE?$S_1 :r_1(X); r_1(Y); r_2(X); r_2(Y); w_2(Y); w_1(X)$$S_2 :r_1(...
23.9k
views
6 answers
44 votes
Kathleen asked Sep 21, 2014
23,883 views
The order of a leaf node in a $B^+$ - tree is the maximum number of (value, data record pointer) pairs it can hold. Given that the block size is $1K\;\text{bytes}$, data ...
24.9k
views
6 answers
70 votes
Kathleen asked Sep 21, 2014
24,910 views
Which one of the following statements is $\text{FALSE}$?Any relation with two attributes is in $\text{BCNF}$A relation in which every key has only one attribute is in $\t...