Skip to content
Official PYQ · 2024

GATE CS 2024 Set 2 Q35 — Relational Model: Relational Algebra

Explain with AI

​​​​​The relation schema, Person (pid, city), describes the city of residence for every person uniquely identified by pid. The following relational algebra operators are available: selection, projection, cross product, and rename.

To find the list of cities where at least 33 persons reside, using the above operators, the minimum number of cross product operations that must be used is

Choose one option
View worked solution

Answer: B

To find the cities where at least 33 distinct persons reside, we need to compare three different tuples from the Person relation to ensure they have the same city but different person IDs (pid).

Let PP be the relation Person(pid, city). To compare three tuples from PP, we must create three renamed instances of PP:

  • P1(pid1,city1)=ρP1(P)P_1(pid_1, city_1) = \rho_{P_1}(P)
  • P2(pid2,city2)=ρP2(P)P_2(pid_2, city_2) = \rho_{P_2}(P)
  • P3(pid3,city3)=ρP3(P)P_3(pid_3, city_3) = \rho_{P_3}(P)

To combine these three relations using only the permitted operators, we perform the cross product of these three instances:

Result=P1×P2×P3\text{Result} = P_1 \times P_2 \times P_3

This requires exactly 22 cross product operations: (P1×P2)×P3(P_1 \times P_2) \times P_3.

We can then apply selection and projection to filter the required cities:

πcity1(σcity1=city2∧city2=city3∧pid1≠pid2∧pid2≠pid3∧pid1≠pid3(P1×P2×P3))\pi_{city_1} \left( \sigma_{city_1 = city_2 \land city_2 = city_3 \land pid_1 \neq pid_2 \land pid_2 \neq pid_3 \land pid_1 \neq pid_3} (P_1 \times P_2 \times P_3) \right)

Why fewer operations are not possible:

  • With 00 cross products, we can only query single tuples, which cannot compare different persons.
  • With 11 cross product (P1×P2P_1 \times P_2), we can only compare at most two tuples, which can identify cities with at least 22 residents, but not 33.

Thus, the minimum number of cross product operations required is 22.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Relational Model: Relational Algebra questions