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 persons reside, using the above operators, the minimum number of cross product operations that must be used is
View worked solution
Answer: B
To find the cities where at least 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 be the relation Person(pid, city). To compare three tuples from , we must create three renamed instances of :
To combine these three relations using only the permitted operators, we perform the cross product of these three instances:
This requires exactly cross product operations: .
We can then apply selection and projection to filter the required cities:
Why fewer operations are not possible:
- With cross products, we can only query single tuples, which cannot compare different persons.
- With cross product (), we can only compare at most two tuples, which can identify cities with at least residents, but not .
Thus, the minimum number of cross product operations required is .
Free practice · Your answers on this page are not saved.
