GATE / CS ARCHIVE

SIMILAR QUESTIONS / DATABASE MANAGEMENT SYSTEMS

Read existential tuple predicates as relational joins

3 questions solved the same way, newest first. Back to Database Management Systems

How these are solved

Identify quantified relation tuples, equate the join attributes, apply the stated constant filters, and project the free tuple components. Extra SQL/RA alternatives must preserve the same quantifier scope.

2 marks · MCQ
Report issue

Translating existential joins into relational algebra

Relational Algebra & Calculus

Question 43, GATE 2026: Relations are R(P,Q) and S(X,Y). The query returns u whenever there exist v,w with (u,v) in R and (v,w) in S. Select the equivalent projection/join expression. The alternatives join P to X, Q to X, P to Y, or Q to Y, and all project P.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Givens and goal

Relations are R(P,Q) and S(X,Y). The query returns u whenever there exist v,w with (u,v) in R and (v,w) in S. Select the equivalent projection/join expression. The alternatives join P to X, Q to X, P to Y, or Q to Y, and all project P.

Approach

Map each quantified variable to its relation attribute, use the repeated variable as the join equality, and project the requested output coordinate.

Step-by-step solution

1. Membership (u,v)∈R means u=R.P and v=R.Q. Membership (v,w)∈S means v=S.X and w=S.Y.
2. The same variable v occurs in both tuples, so qualifying tuple pairs must satisfy R.Q=S.X. This is the equijoin condition; neither R.P nor S.Y is the repeated coordinate.
3. After joining, the query asks only for u. Since u is R.P, project attribute P from the join. Thus the expression is π_P(R ⋈_(R.Q=S.X) S).
4. Option B writes the operands in the reverse order, π_P(S ⋈_(S.X=R.Q) R), which is equivalent for this inner equijoin and projection. Therefore select B.
5. For example, R containing (a,7) and S containing (7,b) must produce a. The two 7 values are the ones that need to match. Joins equating P with X, P with Y, or Q with Y would impose a different condition. The existential variables v and w disappear from the output through projection; ordinary relational algebra uses set semantics here.

Original paper, page 32 · Answer key

2 marks · MCQ
Report issue

Building a relational-calculus join

Relational Algebra & Calculus

Question 39, GATE 2025: Relations are teams(tid,tname) and players(pid,pname,tid). Return names of players on a team named MI. A {p.pname | p∈players ∧ ∃t(t∈teams ∧ p.tid=t.tid ∧ t.tname='MI')}; B the same expression but p∈teams and t∈players; C the expression in A without p.tid=t.tid; D the expression in B without p.tid=t.tid. Which is correct?
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Approach: Translate the desired result into tuple bindings, a join predicate, a selection predicate and a projected attribute.
A returned name must come from a player tuple, so bind p to players. There must exist a team tuple t whose id equals the player’s team id, giving t∈teams and p.tid=t.tid. The selected team must have t.tname='MI'. Project p.pname from precisely those player tuples. These requirements combine exactly as A.
B and D bind p to teams even though teams has no pname attribute, and bind t to players even though players has no tname attribute. They are not correctly typed for the supplied schemas.
C has the right bindings but omits the join. If any team is called MI, its existential condition becomes true for every player, including players on other teams. That illustrates why a selection on team name does not replace the relationship connecting a player to that team.

Original paper, page 39 · Answer key

2 marks · MCQ
Report issue

Equivalent SQL and relational-calculus queries

Relational Algebra & Calculus

Question 35, GATE 2013: Schemas: Students(rollno, sname), Courses(courseno, cname), Registration(rollno, courseno, percent). Desired result is distinct student names scoring>90 in course 107. I SQL SELECT DISTINCT S.sname FROM Students S, Registration R WHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent>90. II relational projection sname after selecting courseno107 and percent>90 from Registration natural-join Students. III tuple calculus {T:∃S∈Students,∃R∈Registration(S.rollno=R.rollno∧R.courseno=107∧R.percent>90∧T.sname=S.sname)}. IV domain calculus {<SN>:∃SR∃RP(<SR, SN>∈Students∧<SR, 107, RP>∈Registration∧RP>90)}. Which equivalent queries? A all four; B I, II, III; C I, II, IV; D II, III, IV.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Each expression joins a student to a registration on roll number, requires course 107 and percent>90, and returns the student name. SQL DISTINCT and set-valued relational algebra/calculi remove duplicate names. Hence all four are equivalent, A, with the tuple-calculus output T understood to have the displayed single sname attribute.

All four forms bind the same join witness: a student row and a registration row with equal rollno, course 107 and percent greater than 90. SQL DISTINCT removes duplicate names; relational projection and calculus use set semantics. The Courses table is not needed because filtering uses its numeric course identifier, not its name. In IV, SR is the shared roll number, SN is the returned name, and RP is the qualifying percentage. In III, the result tuple is understood to have just the sname attribute, matching the projected result schema.

Original paper, page 8 · Answer key