Skip to content
Official PYQ · 2013

GATE CS 2013 Q35 — Tuple Calculus and SQL

Explain with AI

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%90\% in the course numbered 107”

  1. SELECT DISTINCT S.sname FROM Students as S, Registration
        as R WHERE 
        R.rollno=S.rollno AND R.courseno=107 AND R.percent >90
    
  2. ∏sname(σcourseno=107∧percent>90(Registration⋈Students))∏_{sname}(σ_{courseno=107 ∧ percent > 90} (Registration ⋈ Students))
  3. {T∣∃S∈Students,∃R∈Registration(S.rollno=R.rollno\{T \mid ∃S \in Students, ∃R \in Registration ( S.rollno=R.rollno
    ∧R.courseno=107∧R.percent>90∧T.sname=S.sname)}∧ R.courseno=107 ∧ R.percent>90 ∧T.sname=S.sname) \}
  4. {⟨SN⟩∣∃SR∃RP(⟨SR,SN⟩∈Students∧⟨SR,107,RP⟩∈Registration∧RP>90)}\left\{ \langle S_N\rangle \mid ∃S_R∃R_P (\langle S_R,S_N\rangle ∈Students ∧ \\ \langle S_R,107,R_P\rangle ∈Registration ∧ R_P>90) \right\}
Choose one option
View worked solution

Answer: A

To find the correct option, let us analyze each of the given query representations to see if they correctly express the English query: “Find the distinct names of all students who score more than 90%90\% in the course numbered 107”.


I. SQL Query

SELECT DISTINCT S.sname FROM Students as S, Registration as R 
WHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent > 90
  • Join Condition: R.rollno = S.rollno correctly joins the Students and Registration tables.
  • Filtering: R.courseno = 107 AND R.percent > 90 filters for the specified course and score.
  • Projection: SELECT DISTINCT S.sname ensures only distinct student names are returned.

Thus, Query I is correct.


II. Relational Algebra (RA) Query

Πsname(σcourseno=107∧percent>90(Registration⋈Students))\Pi_{sname}(\sigma_{courseno=107 \land percent > 90} (Registration \bowtie Students))

  • Natural Join: Registration ⋈ Students joins the two relations on their common attribute, which is rollno.
  • Selection: σcourseno=107∧percent>90\sigma_{courseno=107 \land percent > 90} filters the joined tuples.
  • Projection: Πsname\Pi_{sname} projects the student names. In relational algebra, the projection operator Π\Pi inherently eliminates duplicate values.

Thus, Query II is correct.


III. Tuple Relational Calculus (TRC) Query

{T∣∃S∈Students,∃R∈Registration(S.rollno=R.rollno∧R.courseno=107∧R.percent>90∧T.sname=S.sname)}\{T \mid \exists S \in Students, \exists R \in Registration ( S.rollno=R.rollno \land R.courseno=107 \land R.percent>90 \land T.sname=S.sname) \}

  • This query defines a target tuple TT containing a single attribute sname (since T.sname=S.snameT.sname = S.sname).
  • It asserts the existence of a student tuple SS and a registration tuple RR such that their rollno values match, the course number is 107107, and the score is greater than 90%90\%.

Thus, Query III is correct.


IV. Domain Relational Calculus (DRC) Query

{⟨SN⟩∣∃SR∃RP(⟨SR,SN⟩∈Students∧⟨SR,107,RP⟩∈Registration∧RP>90)}\left\{ \langle S_N\rangle \mid \exists S_R \exists R_P (\langle S_R,S_N\rangle \in Students \land \langle S_R,107,R_P\rangle \in Registration \land R_P>90) \right\}

  • The domain variables are mapped as follows:
    • For Students(rollno, sname): ⟨SR,SN⟩\langle S_R, S_N\rangle where SRS_R is rollno and SNS_N is sname.
    • For Registration(rollno, courseno, percent): ⟨SR,107,RP⟩\langle S_R, 107, R_P\rangle where SRS_R is rollno, the course number is bound to constant 107107, and RPR_P is percent.
  • The condition RP>90R_P > 90 filters for scores greater than 90%90\%.
  • The output is the domain variable ⟨SN⟩\langle S_N\rangle representing the student's name.

Thus, Query IV is correct.


Conclusion

Since all four queries (I, II, III, and IV) are equivalent and correct, the correct option is A.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions