GATE CS 2013 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0102

Consider the following relational schema.Students(rollno: integer, sname: string)Courses(courseno: integer, cname: string)Registration(rollno: integer, courseno: integer, percent: real)Which of the following queries are equivalent to this query in English?"Find the distinct names of all students who score more than 90\% in the course numbered 107"(I) SELECT DISTINCT S.sname FROM Students AS S, Registration AS R WHERE R.rollno = S.rollno AND R.courseno = 107 AND R.percent > 90(II) \(\Pi_{sname}\big(\sigma_{courseno = 107 \wedge percent > 90}(Registration \bowtie Students)\big)\)(III) \(\{T \mid \exists S \in Students,\ \exists R \in Registration\ (S.rollno = R.rollno \wedge R.courseno = 107 \wedge R.percent > 90 \wedge T.sname = S.sname)\}\)(IV) \(\{\langle S_N \rangle \mid \exists S_R\, \exists R_P\ (\langle S_R, S_N \rangle \in Students \wedge \langle S_R, 107, R_P \rangle \in Registration \wedge R_P > 90)\}\)
  1. A
    I, II, III and IV
  2. B
    I, II and III only
  3. C
    I, II and IV only
  4. D
    II, III and IV only

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solution\[\boxed{\text{join on rollno, keep course } 107 \text{ with percent} > 90, \text{ project sname}}\](I) SQL: joins on rollno, filters, and DISTINCT removes repeated names — equivalent.(II) Relational algebra: the natural join is on rollno (the only common attribute), and projection removes duplicates — equivalent.(III) Tuple relational calculus: the same join, filter and projection — equivalent.(IV) Domain relational calculus: the shared variable \(S_R\) makes the join, \(107\) and \(R_P > 90\) filter — equivalent.All four are equivalent.Answer: A

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com