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”
SELECT DISTINCT S.sname FROM Students as S, Registration as R WHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent >90
beautiful qestion to apply it all
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
it is not necessary according to this image
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 |.
but how is the tuple caculus query correct it prints the whole tupple but it is asked to print only student name to it should be
{T.sname∣∃S∈Students,∃R∈Registration(S.rollno=R.rollno∧R.courseno=107∧R.percent>90∧T.sname=S.sname)}
@hkara That's not how tuple relation calculus defines tuple selection. You can see here:
https://en.wikipedia.org/wiki/Tuple_relational_calculus
∏_{sname}(σ_{courseno}_{=107∧percent>90}(Registration⋈Students))
Here there is no joining condition like Registeration.rollno=Students.rollno is given
@rahul sharma 5
yes , TRC and DRC returns distinct results . https://www.geeksforgeeks.org/gate-gate-cs-2013-question-35/
If you find it is wrong please reply , i also had same doubt
@mehul vaidya
Do TRC and DRC return distinct results (here in case two students with same name & course 107 & 90 % and different roll nos )...above link is not so useful..
I think this will answer all the above questions -
1. How is T in 3rd query gives only T.sname ? why is it not printing the entire row? 2. Why range relation is not specified ?
Reference 1 - https://edux.fit.cvut.cz/archive/B121/BI-DBS/_media/en/lectures/chapt04.pdf Reference 2 - here
. TRC DRC results are distinct always?
Yes. The result of a TRC query is a relation. A relation is defined as a "set" means relations don't contain duplicate elements.