GATE / CS ARCHIVE

GATE CSE 1994 / QUESTION 13(a)

Relational algebra selection and difference

Database Management Systems · Relational Algebra & Calculus · Full GATE CSE 1994 paper

GATE 1994, Q13(a) Descriptive
Report issue

Relational Algebra & Calculus

Question 13(a), GATE 1994: COURSES(cno,cname), primary key cno; STUDENTS(rollno,sname,age,year), primary key rollno; REGISTERED_FOR(cno,rollno), composite primary key (cno,rollno). year denotes the student’s current year of study. GateForum asks for a relational algebra query printing roll numbers of students who HAVE registered for cno 322. GFG instead asks for those who HAVE NOT registered.
Question 13(a), GATE 1994: COURSES(cno,cname), primary key cno; STUDENTS(rollno,sname,age,year), primary key rollno; REGISTERED_FOR(cno,rollno), composite primary key (cno,rollno). year denotes the student’s current year of study. GateForum asks for a relational algebra query printing roll numbers of students who HAVE registered for cno 322. GFG instead asks for those who HAVE NOT registered.
Tap to enlarge
Answer & solution

Answer: Registered: π_rollno(σ_cno=322(REGISTERED_FOR)). Not registered: π_rollno(STUDENTS) − π_rollno(σ_cno=322(REGISTERED_FOR)). (no official key was published)

1. Select registrations for course 322 before projecting rollno, so registrations in other courses do not count.

2. For the registered variant, projection directly returns the wanted roll numbers under the usual valid student-reference assumption. Without that assumption, intersect with π_rollno(STUDENTS).

3. For the not-registered variant, subtract the selected roll-number set from all student roll numbers. Selecting registrations where cno≠322 would be wrong because a student may register for both 322 and another course, or for no course.

  • No single query answers both variants.

Original paper, page 6