GATE CS 2014 · Set-3 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0094

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:\[\Pi_{empId}(employee) - \Pi_{empId}\big(employee \bowtie_{(empId = eId) \wedge (empAge \le depAge)} dependent\big)\]The above query evaluates to the set of empIds of employees whose age is greater than that of
  1. A
    some dependent
  2. B
    all dependents
  3. C
    some of his/her dependents
  4. D
    all of his/her dependents

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solution\[\boxed{\text{all employees} - \text{employees with some own dependent at least as old}}\]The join pairs each employee with his/her own dependents (empId = eId) that are at least as old (empAge \(\le\) depAge). Subtracting these employees leaves those with no such dependent, i.e. older than every one of his/her dependents.Answer: D

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com