Exams › GATE › Technical
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:
Π_empId(employee) - Π_empId(employee ⨝_(empId = eID) ∧ (empAge ≤ depAge) dependent)
The above query evaluates to the set of empIds of employees whose age is greater than that of
- some dependent.
- all dependents.
- some of his/her dependents.
- all of his/her dependents.
Correct answer: all of his/her dependents.
Solution
The query subtracts the empIds of employees who have at least one dependent younger than or equal to them from the set of all empIds, resulting in only those employees whose age is greater than that of all their dependents.
Related GATE Technical questions
⚔️ Practice GATE Technical free + battle 1v1 →