NIMCET, GATE, CUET & CBSE test series are live — start practicing free
syllabuzAI

Tuple Relational Calculus in DBMS | GATE CSE

Learn tuple relational calculus syntax, safe expressions, division with the universal quantifier, max and min queries and DRC basics for GATE CSE DBMS.

6 min read

AS

Aman Singh

Updated 26 November 2026

On this page

Quick answer: Tuple relational calculus (TRC) is a non-procedural query language. A query {t | P(t)} returns every tuple t for which the formula P(t) is true. Formulas are built from atoms (t ∈ R, t.A θ s.B, t.A θ c), the connectives ¬, ∧, ∨ and →, and the quantifiers ∃ and ∀. Only safe expressions, whose results use values from the database or the query, are allowed. Safe TRC, safe domain relational calculus and basic relational algebra have the same expressive power. "For all" queries (division) use ∀, or the equivalent ¬∃ … ¬.

GATE usually shows a TRC expression and asks what it returns, or asks which TRC expression matches an English query or a relational algebra expression. This topic is part of the Relational Algebra and SQL chapter.

General form of a TRC query

{ t∣P(t) }\{\, t \mid P(t) \,\}

  • t is a tuple variable that ranges over tuples.
  • P(t) is a formula. The result is the set of all tuples t that make P(t) true.
  • To return only some attributes, write {t.A, t.B | P(t)}.

Building formulas

Atoms

  • t ∈ R: t is a tuple of relation R.
  • t.A θ s.B: compares attributes of two tuple variables, where θ is one of =, ≠, <, ≤, >, ≥.
  • t.A θ c: compares an attribute with a constant.

Formulas

  • Every atom is a formula. If P₁ and P₂ are formulas, so are ¬P₁, P₁ ∧ P₂, P₁ ∨ P₂ and P₁ → P₂.
  • ∃s (P(s)) and ∀s (P(s)) are formulas, and s is bound inside them. A variable not bound by a quantifier is free, and only the result variable t should be free.

Useful equivalences

These come straight from predicate logic:

∀s (P)≡¬∃s (¬P)P→Q≡¬P∨Q\forall s\,(P) \equiv \neg\exists s\,(\neg P) \qquad P \to Q \equiv \neg P \vee Q

Safe expressions

A TRC expression is safe if every value in its result comes from the constants in the query or the relations it mentions. For example, {t | ¬(t ∈ R)} is unsafe, because infinitely many tuples are not in R. Safe TRC is exactly as expressive as relational algebra.

Relational algebra operations written in TRC

Use Emp(eid, name, sal, dno) and Dept(dno, dname).

Relational algebraTRC
σsal>50000(Emp)\sigma_{sal > 50000}(Emp){t∣t∈Emp∧t.sal>50000}\{t \mid t \in Emp \wedge t.sal > 50000\}
πname(Emp)\pi_{name}(Emp){t.name∣t∈Emp}\{t.name \mid t \in Emp\}
R∪SR \cup S{t∣t∈R∨t∈S}\{t \mid t \in R \vee t \in S\}
R−SR - S{t∣t∈R∧¬(t∈S)}\{t \mid t \in R \wedge \neg(t \in S)\}
R∩SR \cap S{t∣t∈R∧t∈S}\{t \mid t \in R \wedge t \in S\}

Join example: names of employees who work in the 'Sales' department.

{ t.name∣t∈Emp∧∃d (d∈Dept∧d.dno=t.dno∧d.dname=’Sales’) }\{\, t.name \mid t \in Emp \wedge \exists d\,(d \in Dept \wedge d.dno = t.dno \wedge d.dname = \text{'Sales'}) \,\}

Division ("for all") in TRC

Query: students (sid) enrolled in every course, using Enroll(sid, cid) and Course(cid).

With ∀:

{ t.sid∣t∈Enroll∧∀c (c∈Course→∃e (e∈Enroll∧e.sid=t.sid∧e.cid=c.cid)) }\{\, t.sid \mid t \in Enroll \wedge \forall c\,\big(c \in Course \to \exists e\,(e \in Enroll \wedge e.sid = t.sid \wedge e.cid = c.cid)\big) \,\}

Read it as "the student of t, such that for every course c, there is an enrollment of that student in c".

Without ∀:

{ t.sid∣t∈Enroll∧¬∃c (c∈Course∧¬∃e (e∈Enroll∧e.sid=t.sid∧e.cid=c.cid)) }\{\, t.sid \mid t \in Enroll \wedge \neg\exists c\,\big(c \in Course \wedge \neg\exists e\,(e \in Enroll \wedge e.sid = t.sid \wedge e.cid = c.cid)\big) \,\}

Maximum and "more than every" queries

Highest-paid employees:

{ t∣t∈Emp∧¬∃s (s∈Emp∧s.sal>t.sal) }\{\, t \mid t \in Emp \wedge \neg\exists s\,(s \in Emp \wedge s.sal > t.sal) \,\}

Employees earning more than everyone in department 5:

{ t∣t∈Emp∧∀s (s∈Emp∧s.dno=5→t.sal>s.sal) }\{\, t \mid t \in Emp \wedge \forall s\,(s \in Emp \wedge s.dno = 5 \to t.sal > s.sal) \,\}

Note: if department 5 has no employees, the ∀ condition is vacuously true and every employee qualifies.

Domain relational calculus (DRC) in brief

DRC uses domain variables for single attribute values instead of tuple variables:

{ ⟨x1,…,xn⟩∣P(x1,…,xn) }\{\, \langle x_1, \dots, x_n \rangle \mid P(x_1, \dots, x_n) \,\}

Example: names of employees with salary above 50000.

{ ⟨n⟩∣∃e,s,d (⟨e,n,s,d⟩∈Emp∧s>50000) }\{\, \langle n \rangle \mid \exists e, s, d\,(\langle e, n, s, d \rangle \in Emp \wedge s > 50000) \,\}

Expressive power

Basic relational algebra, safe TRC and safe DRC are equally expressive (all are relationally complete). SQL is also relationally complete and adds aggregation, grouping and duplicate (bag) semantics.

Summary table

PatternTRC idiom
A matching tuple exists (join, semi-join)∃s (s∈S∧… )\exists s\,(s \in S \wedge \dots)
No matching tuple (difference)¬∃s (s∈S∧… )\neg\exists s\,(s \in S \wedge \dots)
For all (division)∀s (s∈S→… )\forall s\,(s \in S \to \dots)
Maximum¬∃s (s∈R∧s.A>t.A)\neg\exists s\,(s \in R \wedge s.A > t.A)
Minimum¬∃s (s∈R∧s.A<t.A)\neg\exists s\,(s \in R \wedge s.A < t.A)

Exam tips

  • Pair ∃ with ∧ and ∀ with →. Most wrong options in GATE swap these.
  • Read a TRC expression from the inside out, translating each quantifier into English as you go.
  • For "maximum" or "minimum", look for a ¬∃ that says "no better tuple exists".

Common mistakes

  • Using ∧ inside ∀. ∀s (s ∈ S ∧ P) claims every tuple in the universe is in S.
  • Using → inside ∃. ∃s (s ∈ S → P) is true almost trivially, so use ∧.
  • Forgetting vacuous truth when the range of ∀ is empty.
  • Writing a negation with no positive range such as t ∈ R, which makes the query unsafe.

Practice questions

Q1. What does this return?

{ t∣t∈Emp∧¬∃s (s∈Emp∧s.sal<t.sal) }\{\, t \mid t \in Emp \wedge \neg\exists s\,(s \in Emp \wedge s.sal < t.sal) \,\}

Answer: The employees with the minimum salary.

Q2. Is {t | ¬(t ∈ Emp)} a valid query?

Answer: No. It is unsafe, because its result would be infinite.

Q3. Write in TRC: employees who work in a department named 'HR'.

Answer:

{ t∣t∈Emp∧∃d (d∈Dept∧d.dno=t.dno∧d.dname=’HR’) }\{\, t \mid t \in Emp \wedge \exists d\,(d \in Dept \wedge d.dno = t.dno \wedge d.dname = \text{'HR'}) \,\}

FAQs

What is tuple relational calculus?

It is a declarative query language. A query describes the tuples you want, {t | P(t)}, using predicate-logic formulas over relations.

What is a safe expression in relational calculus?

It is an expression whose result uses only values that appear in the database or the query, so the result is always finite.

Is relational calculus more powerful than relational algebra?

No. Safe tuple relational calculus, safe domain relational calculus and basic relational algebra can express exactly the same queries.

How is division written in tuple relational calculus?

With a universal quantifier: for every tuple of the divisor relation, there must be a matching tuple in the dividend.

What is the difference between TRC and DRC?

TRC variables range over whole tuples, while DRC variables range over single attribute values.

Conclusion

Translate English to TRC with the same habits as predicate logic: ∃ with ∧, ∀ with →, and ¬∃ for "no better tuple". Then match TRC and relational algebra using the summary table. Continue with SQL queries, revise relational algebra, or go back to the Relational Algebra and SQL chapter.

Concept Check

MEDIUM

Consider two transactions T1T_1 and T2T_2, and four schedules S1,S2,S3,S4S_1, S_2, S_3, S_4 of T1T_1 and T2T_2 as given below:

T1:R1[x] W1[x] W1[y]T_1: R_1[x]\ W_1[x]\ W_1[y] T2:R2[x] R2[y] W2[y]T_2: R_2[x]\ R_2[y]\ W_2[y]

S1:R1[x] R2[x] R2[y] W1[x] W1[y] W2[y]S_1: R_1[x]\ R_2[x]\ R_2[y]\ W_1[x]\ W_1[y]\ W_2[y] S2:R1[x] R2[x] R2[y] W1[x] W2[y] W1[y]S_2: R_1[x]\ R_2[x]\ R_2[y]\ W_1[x]\ W_2[y]\ W_1[y] S3:R1[x] W1[x] R2[x] W1[y] R2[y] W2[y]S_3: R_1[x]\ W_1[x]\ R_2[x]\ W_1[y]\ R_2[y]\ W_2[y] S4:R2[x] R2[y] R1[x] W1[x] W1[y] W2[y]S_4: R_2[x]\ R_2[y]\ R_1[x]\ W_1[x]\ W_1[y]\ W_2[y]

Which of the above schedules are conflict-serializable?

Suggested for you