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” (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)) (III) {T | ∃S ∈ Students, ∃R ∈ Registration (S.rollno = R.rollno ∧R. courseno = 107 ∧ R.percent > 90 ∧ T.sname = S. sname)} (IV) {〈SN〉 | ∃SR∃RP(〈SR, SN〉 ∈ Students ∧ 〈SR, 107, RP〉 ∈ Registration ∧ RP > 90)}
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” (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)) (III) {T | ∃S ∈ Students, ∃R ∈ Registration (S.rollno = R.rollno ∧R. courseno = 107 ∧ R.percent > 90 ∧ T.sname = S. sname)} (IV) {〈SN〉 | ∃SR∃RP(〈SR, SN〉 ∈ Students ∧ 〈SR, 107, RP〉 ∈ Registration ∧ RP > 90)} Correct Answer I, II, III and IV
The correct answer is option 1.
Key Points
Structured Query Language, Relational algebra, Tuple relational calculus, and domain relational calculus all are representing the same. i.e, all these expressions representing finding 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
The above query is Structured Query Language, It takes two tables are student and registration and cross-product the tuples based on Rollno attribute those tuple course number should be 107 and percentage more than 90%.
(II) Πsname (σcourseno = 107∧percent>90 (Registration ⋈ Students))
The above query is Relational algebra. It first performs a natural join of Students and Registration and natural join implicitly join on the basis of the common attribute, which here is roll no. Select operation( sigma) keeps only those rows where the student is registered for course no 107, and the percentage is more than 90%. And then the projection operation (pi) projects only distinct student names from the set.
(III) {T | ∃S ∈ Students, ∃R ∈ Registration (S.rollno = R.rollno ∧R. courseno = 107 ∧ R.percent > 90 ∧ T.sname = S. sname)}
The above query is Tuple relational calculus. It is not a procedural language. It just represents a declarative mathematical expression. It finding the distinct names of all students who score more than 90 % in the course numbered 107.
(IV) {〈SN〉 | ∃SR∃RP(〈SR, SN〉 ∈ Students ∧ 〈SR, 107, RP〉 ∈ Registration ∧ RP > 90)}
The above query is domain relational calculus. It is not a procedural language. It just represents a declarative mathematical expression. And SN is a domain variable. It finding the distinct names of all students who score more than 90 % in the course numbered 107.
Hence the correct answer is I, II, III, and IV.