Question

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

empAge(empNo,age)\text{empAge}(\text{empNo}, \text{age})

Consider the following relational algebra expression:

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

What does the above expression generate?

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2021 answer key

Solution

Analyze the theta-join condition on self-joined relation empAge to determine which employee records survive the join.

The expression performs a theta-join between empAge and a renamed copy ρempNo1,age1(empAge)\rho_{\text{empNo1}, \text{age1}}(\text{empAge}) with condition age>age1\text{age} > \text{age1}:

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

An employee tuple with age AA successfully pairs with at least one tuple with age A1A_1 in the second relation if and only if there exists some employee in the company who has a strictly smaller age (A>A1A > A_1).

  • If an employee has the minimum age in the company, there is no employee with age strictly smaller than theirs; thus no tuple satisfies age>age1\text{age} > \text{age1}, and their employee number will never appear in the join result.
  • For every employee whose age is NOT the minimum, there exists at least one employee with a strictly lower age (namely, the employee(s) with minimum age), so this condition evaluates to true and their empNo is included.

Therefore, the expression generates the employee numbers of all employees whose age is not the minimum (option C).

Final answer

C

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2021 Computer Science and Information Technology (CS, Set-1)
Question
37 of 65, printed as CS Q.27
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.