Skip to main content

GATE CSE 2021Databases › Relational Algebra & CalculusVerified

GATE CSE 2021 PYQ: The following relation records the age of 500 500 500 employees of a company, where e m p N o empNo e m pN o…

The following relation records the age of 500 employees of a company, where empNoempNo (indicating the employee number) is the key:

empAge(empNo‾,age)empAge(\underline{empNo},age)

Consider the following relational algebra expression:

ΠempNo(empAge⋈(age>age1)ρempNo1,age1(empAge))\Pi_{empNo}(empAge \Join_{(age>age1)} \rho_{empNo1,age1}(empAge))

What does the above expression generate?

  1. A
    Employee numbers of only those employees whose age is the maximum
  2. B
    Employee numbers of only those employees whose age is more than the age of exactly one other employee
  3. C
    Employee numbers of all employees whose age is not the minimum
    Correct answer
  4. D
    Employee numbers of all employees whose age is the minimum

Answer

(C) Employee numbers of all employees whose age is not the minimum

Approach

The expression is a self-join of empAge with a renamed copy of itself. The join condition age > age1 keeps only pairs where the left employee is older than the right employee. Projecting empNo from the left copy therefore returns every employee who is older than at least one other employee. This is exactly the set of employees whose age is not the minimum; employees at the minimum age cannot satisfy age > age1.

The self-join keeps left-side employees whose age is strictly greater than at least one other employee's age. This is equivalent to excluding only employees who have the minimum age. Therefore the projected empNo list is 'Employee numbers of all employees whose age is not the minimum', i.e. option C.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.