Discussion
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
Answer: B
The minimum is 2 cross products.
Without aggregation, 'at least 3 persons' must be expressed by finding three distinct persons in the same city. Rename gives three copies of Person, P1, P2 and P3, and two cross products combine them:
\[ \pi_{P1.city}(\sigma_{\theta}(P1 \times P2 \times P3)) \]
where \(\theta\) requires equal cities and pairwise different pids (P1.pid \(\lt\) P2.pid \(\lt\) P3.pid will do).
One cross product only compares two tuples at a time, which can show a city with at least 2 persons but not 3. Three or four cross products would work but are not the minimum.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development