GATE Computer Science · Databases, Theory of Computation, and Compiler Design · easy
In relational algebra, given relations Enrollment(studentId, courseId) and RequiredCourse(courseId), which operator directly returns the studentId values of students who are enrolled in EVERY course listed in RequiredCourse?
Published · Last updated · checked before publication — how we verify questions
Options
Answer: B. Relational division (Enrollment ÷ RequiredCourse) for universal queries
Relational division is the operator designed for universal quantification, queries of the form 'find all x related to every y in a given set'. For Enrollment(studentId, courseId) divided by RequiredCourse(courseId), the result contains each studentId for which the set of paired courseId values includes every tuple in RequiredCourse. The attributes of the divisor must be a subset of the dividend's attributes, and the result schema is the remaining attributes, here studentId alone. Division can be written with basic operators as pi_studentId(Enrollment) minus pi_studentId((pi_studentId(Enrollment) x RequiredCourse) minus Enrollment). The common trap is to reach for a join or product, which only expresses existential matching, meaning at least one match, rather than 'for all'. Extra courses taken by a student do not disqualify them, because only coverage of the divisor matters.
Why the other options are wrong
- A. Cartesian product (Enrollment x RequiredCourse) paired across rows — The Cartesian product pairs every enrollment row with every required course, producing a larger relation with a combined schema and no filtering for coverage. It can be a building block inside the division expression, but by itself it does not return the studentIds enrolled in every required course.
- C. Natural join (Enrollment |x| RequiredCourse) projected on studentId — The natural join on courseId keeps enrollment rows whose course appears in RequiredCourse, so projecting studentId returns students enrolled in at least one required course. That is an existential condition, not the universal one the question asks for.
- D. Set union (Enrollment U RequiredCourse) across incompatible arities — Union combines two union-compatible relations with the same number and domains of attributes. Enrollment has two attributes and RequiredCourse has one, so the union is not even defined, and union would not test for universal coverage anyway.
More Databases, Theory of Computation, and Compiler Design questions
- Which two statements regarding formal language classes and bottom-up LR parsers are always true? (Select two.)
- Consider a relation schema R(A, B, C, D, E) with the functional dependency set F = {AB -> C, C -> D, D -> B, D -> E}…
- Consider two concurrent transactions T1 and T2 in schedule S: R1(X), W2(X), W1(Y), R2(Y). Which two statements about…
- Consider a relation R(A, B, C) with functional dependencies F = {AB -> C, C -> B}. What is the highest normal form…
All Databases, Theory of Computation, and Compiler Design questions and the topic overview →
GATE is a mark of the Indian Institute of Science and the Indian Institutes of Technology. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by the GATE Committee.