GATE CS 2024 · Set-2 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0051

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 3 persons reside, using the above operators, the minimum number of cross product operations that must be used is
  1. A
    1
  2. B
    2
  3. C
    3
  4. D
    4

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

Show the worked solutionA city qualifies if three different persons live there. Without aggregation, three tuples of Person must be compared within a single row, so three copies are needed (via rename):\[\pi_{P1.city}\big(\sigma_{P1.city=P2.city=P3.city\ \wedge\ P1.pid\ne P2.pid\ \wedge\ P2.pid\ne P3.pid\ \wedge\ P1.pid\ne P3.pid}(P1\times P2\times P3)\big)\]Joining 3 copies takes \(3-1=2\) cross products, and fewer copies cannot show three different pids in one tuple.Answer: B

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