Question
Consider the following relational schema.
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)
(III)
(IV)
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 > 90This correctly joins
StudentsandRegistrationonrollno, applies the filterscourseno = 107andpercent > 90, and returns distinct student names (sname). This is equivalent. -
(II) Relational Algebra Expression:
The natural join automatically joins on common attribute
rollno. Selection filters rows wherecourseno = 107andpercent > 90. Projection in relational algebra inherently eliminates duplicates. This is equivalent. -
(III) Tuple Relational Calculus (TRC):
This specifies tuples with attribute
snamebelonging to students registered for course 107 with percent exceeding 90. Set semantics guarantees distinct results. This is equivalent. -
(IV) Domain Relational Calculus (DRC):
Here is the domain variable for student name, represents
rollno, and representspercent. The conditions check existence of matching tuples inStudentsandRegistrationwhere course is 107 and percent is greater than 90. Set semantics ensures distinct values of . This is equivalent.
All four queries (I, II, III, and IV) are equivalent to the English query. Therefore, option (A) is correct.
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.