in Databases edited by
48 votes
48 votes

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”

  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))$
  3. $\{T \mid ∃S \in Students, ∃R \in Registration ( S.rollno=R.rollno$
    $∧ R.courseno=107 ∧ R.percent>90 ∧T.sname=S.sname) \}$
  4. $\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\}$
  1. I, II, III and IV
  2. I, II and III only
  3. I, II and IV only
  4. II, III and IV only
in Databases edited by


Why not T.sname in 3rd option? It is causing hell a lot of confusion. In every other TRC question the attribute to be printed is given in LHS of |.

Please someone explain the IV query.
TRC & DRC removes duplicate result same as the DISTINCT keyword in SQL.

2 Answers

38 votes
38 votes
Best answer
Answer: A

Four queries given in SQL, RA, TRC and DRC in four statements respectively retrieve the required information.
selected by


For people having problem that why option 3 is corect as it is printing whole tuple... actually it is not printing whole tuple  ,T.sname=S.sname will print the student name from student table  ....(T is a free variable )
Thanks a lot for this !
T is a free variable but to print only student names we should have T.Sname on the left hand side of the | instead of T.

If T itself returns student names then T.sname dose not make any sense. It is like writing sname.sname.
14 votes
14 votes
Option A:

This is a SQL query expression. It first perform a cross product of Students 
and Registration, then WHERE clause only keeps those rows in the cross product 
set where the student is registered for course no 107, and percentage is > 90. 
Then select distinct statement gives the distinct names of those students as the 
result set.

Option B:

This is a relational algebra expression. It first perform a NATURAL JOIN 
of Students and Registration (NATURAL JOIN implicitly joins on the basis 
of common attribute, which here is rollno ), then the select operation( sigma) 
keeps only those rows where the student is registered for courseno 107,
and percentage is > 90. And then the projection operation (pi) projects only 
distinct student names from the set.

Note: Projection operation (pi) always gives the distinct result.
Option C:

This is a Tuple Relational Calculus (TRC) language expression,
It is not a procedural language (i.e. it only tells “what to do”, 
not “how to do”). It just represents a declarative mathematical 

Here T is a Tuple variable.

From left to right, it can be read like this, “It is a set of
tuples T, where, there exists a tuple S in Relation Students, and 
there exist a tuple R in relation Registration, such that 
S.rollno = R.rollno AND R.couseno = 107 AND R.percent > 90 AND 
T.sname = S.sname”. And the schema of this result is (sname), i.e. each 
tuple T will contain only student name, because only T.sname has been defined 
in the expression.

As TRC is a mathematical expression, hence it is expected to give only distinct result set.
Option D:

This is a Domain Relational Calculus (DRC) language expression. 
This is also not procedural. Here SN is a Domain Variable. It can be read 
from left to right like this “The set of domain variable SN, where, 
there exist a domain variable SR , and a domain variable Rp, such that, 
SN and SR domain variables is in relation Students and SR,107,RP is a domain
variables set in relation Registration, AND RP > 90 “

Above, SN represents sname domain attribute in Students relation, SR 
represents rollno domain attribute in Students relation, and RP represents 
percentage domain attribute in Registration relation.
The schema for the result set is (SN), i.e. only student name.

As DRC is a mathematical expression, hence it is expected to
give only distinct result set.


So clearly all options are correct.

1 comment

Geeks for geeks 😂😂

Related questions