Question
Consider the relational schema given below, where eId of the relation dependent is a foreign key referring to empId of the relation employee. Assume that every employee has at least one associated dependent in the dependent relation.
employee (empId, empName, empAge)
dependent(depId, eId, depName, depAge)
Consider the following relational algebra query:
The above query evaluates to the set of empIds of employees whose age is greater than that of
Official answer and solution
- Official answer
- D
- From
- Official GATE 2014 answer key
Solution
Interpret the relational algebra query step-by-step using set difference to express universal quantification.
-
Analyze Sub-expressions:
- gives the set of all employee IDs in the company.
- The join matches an employee with a dependent of that employee such that the employee's age is less than or equal to the dependent's age ().
- of this join produces the IDs of all employees who have at least one dependent whose age is greater than or equal to the employee's age.
-
Apply Set Difference:
Subtracting these yields all employees who do NOT have any dependent with .
-
Conclusion:
Since every employee has at least one associated dependent, this set contains employees for whom every single one of their dependents satisfies .
In plain English, this represents the set of employees whose age is greater than that of all of his/her dependents (option D).
D
Confusing 'all of his/her dependents' with 'all dependents in the company' (option B), which would compare against every dependent globally.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 3
- Question
- 40 of 65, printed as CS Q.30
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.