in Databases edited by
14,915 views
52 votes
52 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
by
14.9k views

9 Comments

beautiful qestion to apply it all yes

6
6
@Arjun Sir please help. There is no attribute name (T.attrname) given in left side of '|' in choice 3. Then how is it correct?
1
1
Hello Arjun Sir, Can u please help me to understand , we have not included joining condition in Option 2 (Relational Algebra) , so it can be correct?
0
0
edited by

TRC and DRC -> https://www.w3schools.in/dbms/relational-calculus/

I think in third part. $T∈Students$ is missing. Ideally it should be -

$ \left \{   T ∣  T∈Students  ∧ ∃S∈Students,∃R∈Registration(S.rollno=R.rollno∧R.courseno=107∧ R.percent>90∧T.sname=S.sname) \right \}$

Refer - https://gateoverflow.in/1331/gate2009-45

2
2

it is not necessary according to this image

7
7
In DRC, for all the attributes in a table the variables shld b mentioned right

ex: student(a,b,c,d)

but in 4th option only required var is mentioned!

in this case how the system identifies a var is assigned to a particular attribute in a table?
1
1

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 |.

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

2 Answers

41 votes
41 votes
Best answer
Answer: A

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

4 Comments

Thanks a lot for this !
0
0
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.
1
1
Got it!
0
0
16 votes
16 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 
expression.

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 😂😂
1
1
Answer:

Related questions