GATE / CS ARCHIVE

GATE CSE 2013 / QUESTION 35

Equivalent SQL and relational-calculus queries

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

GATE 2013, Q35 2 marks · MCQ
Report issue

Relational Algebra & Calculus

Question 35, GATE 2013: Schemas: Students(rollno, sname), Courses(courseno, cname), Registration(rollno, courseno, percent). Desired result is distinct student names scoring>90 in course 107. I SQL SELECT DISTINCT S.sname FROM Students S, Registration R WHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent>90. II relational projection sname after selecting courseno107 and percent>90 from Registration natural-join Students. III tuple calculus {T:∃S∈Students,∃R∈Registration(S.rollno=R.rollno∧R.courseno=107∧R.percent>90∧T.sname=S.sname)}. IV domain calculus {<SN>:∃SR∃RP(<SR, SN>∈Students∧<SR, 107, RP>∈Registration∧RP>90)}. Which equivalent queries? A all four; B I, II, III; C I, II, IV; D II, III, IV.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Each expression joins a student to a registration on roll number, requires course 107 and percent>90, and returns the student name. SQL DISTINCT and set-valued relational algebra/calculi remove duplicate names. Hence all four are equivalent, A, with the tuple-calculus output T understood to have the displayed single sname attribute.

All four forms bind the same join witness: a student row and a registration row with equal rollno, course 107 and percent greater than 90. SQL DISTINCT removes duplicate names; relational projection and calculus use set semantics. The Courses table is not needed because filtering uses its numeric course identifier, not its name. In IV, SR is the shared roll number, SN is the returned name, and RP is the qualifying percentage. In III, the result tuple is understood to have just the sname attribute, matching the projected result schema.

Original paper, page 8 · Answer key