Relational Algebra · Databases
31 questions · asked in 19 of 27 years (2000–2026)
MCQ 27 · MSQ 1 · NAT 31-mark 17 · 2-mark 14
2000Questions per year2026
Questions 16–20 of 31
Consider the following relational schema:
Consider the following tuple relational calculus query.
If a student needs to score more than 35 marks to pass an exam, what does the query return?
Student(school-id,sch-roll-no,sname,saddress)
School(school-id,sch-name,sch-address,sch-phone)
Enrolment(school-id,sch-roll-no,erollno,examname)
ExamResult(erollno,examname,marks) Consider the following tuple relational calculus query.
If a student needs to score more than 35 marks to pass an exam, what does the query return?
Answer: (C)
For each school id in Enrolment, the query makes two counts:
- Top: the enrolment tuples of school that have a matching ExamResult row (same erollno and examname) with . These are the passes.
- Bottom: all enrolment tuples of school .
It then checks . A student needs more than 35 marks to pass, so this is the pass percentage of the school.
Both counts run over all of the school's enrolments, with no grouping by examname. So the percentage is taken over all exams taken together, not exam by exam.
- (A) is wrong: the query can return schools.
- (B) is wrong: the top count needs marks , not just an enrolment.
- (D) is wrong: the percentage is not computed separately for each exam.
Answer: (C)
- Top: the enrolment tuples of school that have a matching ExamResult row (same erollno and examname) with . These are the passes.
- Bottom: all enrolment tuples of school .
It then checks . A student needs more than 35 marks to pass, so this is the pass percentage of the school.
Both counts run over all of the school's enrolments, with no grouping by examname. So the percentage is taken over all exams taken together, not exam by exam.
- (A) is wrong: the query can return schools.
- (B) is wrong: the top count needs marks , not just an enrolment.
- (D) is wrong: the percentage is not computed separately for each exam.
Answer: (C)
Let R and S be two relations with the following schema
R (,R1,R2,R3)
S (,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are equivalent?
I.
II.
III.
IV.
R (,R1,R2,R3)
S (,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are equivalent?
I.
II.
III.
IV.
Answer: (D)
R and S share only the attributes and . So joins tuples that agree on both and (the whole key).
I keeps the of every pair that occurs in both R and S. That is , which is III. So I and III are equivalent.
IV uses with and . So the inner part is , and IV is the same as III.
II is . This joins on alone, so it gives the values present in both relations, even if they come with different values. Counterexample: has pairs and has . Then I gives , but II gives . So II is not equivalent.
I, III and IV are equivalent.
Answer: (D)
I keeps the of every pair that occurs in both R and S. That is , which is III. So I and III are equivalent.
IV uses with and . So the inner part is , and IV is the same as III.
II is . This joins on alone, so it gives the values present in both relations, even if they come with different values. Counterexample: has pairs and has . Then I gives , but II gives . So II is not equivalent.
I, III and IV are equivalent.
Answer: (D)
Consider the following relation schemas :
b-Schema = (b-name, b-city, assets)
a-Schema = (a-num, b-name, bal)
d-Schema = (c-name, a-number)
Let branch, account and depositor be respectively instances of the above schemas. Assume that account and depositor relations are much bigger than the branch relation.
Consider the following query:
Which one of the following queries is the most efficient version of the above query ?
b-Schema = (b-name, b-city, assets)
a-Schema = (a-num, b-name, bal)
d-Schema = (c-name, a-number)
Let branch, account and depositor be respectively instances of the above schemas. Assume that account and depositor relations are much bigger than the branch relation.
Consider the following query:
Which one of the following queries is the most efficient version of the above query ?
Answer: (A)
Rule: do selections early, and join small results before big relations. and are much bigger than .
(C), (D) are invalid. They apply to , but has no attribute.
(B) joins with first. Both are big, and the Agra filter on is applied only afterwards. So the big join covers the negative-balance accounts of every branch.
(A) first selects the Agra branch (a few tuples), joins it with and then keeps only . Only this small set of accounts is joined with the big relation. This is the cheapest plan.
Answer: (A)
(C), (D) are invalid. They apply to , but has no attribute.
(B) joins with first. Both are big, and the Agra filter on is applied only afterwards. So the big join covers the negative-balance accounts of every branch.
(A) first selects the Agra branch (a few tuples), joins it with and then keeps only . Only this small set of accounts is joined with the big relation. This is the cheapest plan.
Answer: (A)
Consider a selection of the form , where r is a relation with 1000 tuples. Assume that the attribute values for A among the tuples are uniformly distributed in the interval [0, 500]. Which one of the following options is the best estimate of the number of tuples returned by the given selection query ?
Answer: (D)
The values of are uniformly spread over , so the fraction of tuples with is the length of divided by the length of :
Number of tuples .
Answer: (D)
Number of tuples .
Answer: (D)
Information about a collection of students is given by the relation studinfo(, name, sex). The relation enroll(studId, courseId) gives which student has enrolled for (or taken) what course(s). Assume that every course is taken by at least one male and at least one female student. What does the following relational algebra expression represent?
Answer: (B)
Read the expression from the inside.
1. is the set of ids of female students.
2. Its cross product with gives every pair (female student, course).
3. Subtracting removes the pairs where the student really took the course. What remains is every pair (female student , course ) where is not enrolled in .
4. Projecting on gives the courses where at least one female student is not enrolled.
Since every course has at least one female student, the female students enrolled in such a course are some, but not all, of the female students: a non-empty proper subset.
Example: students 1 (M), 2 (F), 3 (F); enroll = . The pairs are . After subtracting enroll only is left, so the result is . Only female student 2 is in .
(A) is the opposite: such courses are left out of the result. (C) is not what the expression computes, since it looks only at female students.
Answer: (B)
1. is the set of ids of female students.
2. Its cross product with gives every pair (female student, course).
3. Subtracting removes the pairs where the student really took the course. What remains is every pair (female student , course ) where is not enrolled in .
4. Projecting on gives the courses where at least one female student is not enrolled.
Since every course has at least one female student, the female students enrolled in such a course are some, but not all, of the female students: a non-empty proper subset.
Example: students 1 (M), 2 (F), 3 (F); enroll = . The pairs are . After subtracting enroll only is left, so the result is . Only female student 2 is in .
(A) is the opposite: such courses are left out of the result. (C) is not what the expression computes, since it looks only at female students.
Answer: (B)
Keep practising
Topics in Databases
ER ModelRelational Schema
Relational AlgebraYou are here
Tuple CalculusSQLIntegrity ConstraintsNormal FormFile SystemTransaction