Question

Consider the following relational schema.

Students(rollno:integer,sname:string)\text{Students}(\text{rollno}: \text{integer}, \text{sname}: \text{string})
Courses(courseno:integer,cname:string)\text{Courses}(\text{courseno}: \text{integer}, \text{cname}: \text{string})
Registration(rollno:integer,courseno:integer,percent:real)\text{Registration}(\text{rollno}: \text{integer}, \text{courseno}: \text{integer}, \text{percent}: \text{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) Πsname(σcourseno=107∧percent>90(Registration⋈Students))\Pi_{\text{sname}}(\sigma_{\text{courseno}=107 \land \text{percent}>90}(\text{Registration} \bowtie \text{Students}))

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

(IV) {⟨SN⟩∣∃SR,∃RP(⟨SR,SN⟩∈Students∧⟨SR,107,RP⟩∈Registration∧RP>90)}\{\langle SN \rangle \mid \exists SR, \exists RP (\langle SR, SN \rangle \in \text{Students} \land \langle SR, 107, RP \rangle \in \text{Registration} \land RP > 90)\}

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2013 answer key

Solution

Verify each query formulation (SQL, Relational Algebra, TRC, DRC) against the English specification.

The English specification is: "Find the distinct names of all students who score more than 90% in the course numbered 107".

Let us evaluate each query representation:

  • (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
    

    This correctly joins Students and Registration on rollno, applies the filters courseno = 107 and percent > 90, and returns distinct student names (sname). This is equivalent.

  • (II) Relational Algebra Expression:

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

    The natural join automatically joins on common attribute rollno. Selection filters rows where courseno = 107 and percent > 90. Projection Π\Pi in relational algebra inherently eliminates duplicates. This is equivalent.

  • (III) Tuple Relational Calculus (TRC):

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

    This specifies tuples TT with attribute sname belonging to students registered for course 107 with percent exceeding 90. Set semantics guarantees distinct results. This is equivalent.

  • (IV) Domain Relational Calculus (DRC):

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

    Here SNSN is the domain variable for student name, SRSR represents rollno, and RPRP represents percent. The conditions check existence of matching tuples in Students and Registration where course is 107 and percent is greater than 90. Set semantics ensures distinct values of SNSN. This is equivalent.

All four queries (I, II, III, and IV) are equivalent to the English query. Therefore, option (A) is correct.

Final answer

A

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2013 Computer Science and Information Technology (CS)
Question
35 of 65, printed as CS Q.35
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.