Information about a collection of students is given by the relation…

2007

Information about a collection of students is given by the relation studinfo(studId, name, sex). The relation enroll(studId, courseId) gives which student has enrolled for (or taken) that course(s). Assume that every course is taken by at least one male and at least one female student. What does the following relational algebra expression represent?

  1. A.

    Courses in which all the female students are enrolled.

  2. B.

    Courses in which a proper subset of female students are enrolled.

  3. C.

    Courses in which only male students are enrolled.

  4. D.

    None of the above

Attempted by 35 students.

Show answer & explanation

Correct answer: B

Key idea: interpret each part of the expression step by step.

  • Let F = π_studId(σ_sex = "female"(studInfo)). This is the set of all female student IDs.

  • Let C = π_courseId(enroll). This is the set of all course IDs.

  • F × C produces all pairs (femaleStudent, course) for every female and every course — i.e., the hypothetical relation where every female student is enrolled in every course.

  • Subtracting enroll removes the pairs where the female student actually is enrolled. The remainder is the set of (femaleStudent, course) pairs where that female is not enrolled in that course.

  • Projecting on courseId therefore yields all courses for which there exists at least one female student who is not enrolled in that course.

Conclusion: The expression returns course IDs whose enrolled female students form a proper subset of all female students (i.e., at least one female is not enrolled in the course).

Relation to the choices: The description 'Courses in which a proper subset of female students are enrolled' matches this meaning. The description 'Courses in which all the female students are enrolled' is the opposite; 'Courses in which only male students are enrolled' is inconsistent with the stated assumption that every course has at least one female student.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir