VOOZH about

URL: https://www.geeksforgeeks.org/dbms/tuple-relational-calculus-trc-in-dbms/

⇱ Tuple Relational Calculus (TRC) in DBMS - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Tuple Relational Calculus (TRC) in DBMS

Last Updated : 24 Apr, 2026

Tuple Relational Calculus (TRC) is a non-procedural query language used to retrieve data from relational databases by describing the properties of the required data (not how to fetch it). It is based on first-order predicate logic and uses tuple variables to represent rows of tables.

Syntax: The basic syntax of TRC is as follows:

{ t | P(t) }

  • t: Tuple variable (row placeholder)
  • P(t): Predicate condition to satisfy
  • {}: Denotes a set of result tuples

Logical Operators in TRC:

  • ∧: AND
  • ∨: OR
  • Β¬: NOT

Quantifiers:

  • βˆƒ t ∈ r (Q(t)) β†’ There exists a tuple t in relation r satisfying predicate Q(t)
  • βˆ€ t ∈ r (Q(t)) β†’ For all tuples t in relation r, predicate Q(t) holds

For example, let's say we have a table called "Employees" with the following attributes:

Employee ID
Name
Salary
Department ID

To retrieve the names of all employees who earn more than $50,000 per year, we can use the following TRC query:

{ t.Name | Employees(t) ∧ t.Salary > 50000 }

Explanation:

  • Employees(t) means t is a tuple from the Employees table.
  • ∧ (AND) is used to add a condition on salary.
  • The result is a set of tuples where each employee earns more than $50,000.

TRC is non-procedural - it specifies what data to retrieve, not how to retrieve it.

While expressive, TRC is more abstract and mainly used in academic or theoretical contexts, not practical database systems.

Tuple Relational Query

In Tuple Calculus, a query is expressed as

{t| P(t)}

  • t represents the resulting tuples.
  • P(t) is a predicate (a condition that must be true for t to be included in the resul

P(t) may have various conditions logically combined with OR (∨), AND (∧), NOT(Β¬). 

It also uses quantifiers:

  • βˆƒ t ∈ r (Q(t)) = ”there exists” a tuple in t in relation r such that predicate Q(t) is true. 
  • βˆ€ t ∈ r (Q(t)) = Q(t) is true "for all" tuples in relation r.

Domain Relational Calculus (DRC)

Domain Relational Calculus is similar to Tuple Relational Calculus, where it makes a list of the attributes that are to be chosen from the relations as per the conditions.

{<a1,a2,a3,.....an> | P(a1,a2,a3,.....an)}

where a1,a2,...an are the attributes of the relation and P is the condition.

Tuple Relational Calculus Examples

Table Customer

Customer nameStreetCity
JohnA7Chicago
EmmaB6Houston
OliviaD9Dallas
SophiaA5Chicago

Table Branch

Branch nameBranch City
ABCChicago
DEFDallas
GHIHouston

Table Account

Account numberBranch nameBalance
1111ABC50000
1112DEF10000
1113GHI9000
1114ABC7000

Table Loan

Loan numberBranch nameAmount
L33ABC10000
L35DEF15000
L49GHI9000
L98DEF65000

Table Borrower

Customer nameLoan number
JohnL33
EmmaL49
SophiaL98

Table Depositor

Customer nameAccount number
John1111
Emma1113
Olivia1114

Example 1: Find the loan number, branch, and amount of loans greater than or equal to 10000 amount.

{t| t ∈ loan ∧ t[amount]>=10000}

Resulting relation: 

Loan numberBranch nameAmount
L33ABC10000
L35DEF15000
L98DEF65000

In the above query, t[amount] is known as a tuple variable.

Example 2: Find the loan number for each loan of an amount greater or equal to 10000.  

{ t[loan-number] | t ∈ loan ∧ t[amount] β‰₯ 10000 }

Resulting relation: 

Loan number
L33
L35
L98

It retrieves the loan numbers of all tuples in the loan relation where the amount is greater than or equal to 10000.

Example 3: Find the names of all customers who have a loan and an account at the bank.  

{ t.customer_name |
βˆƒ s ∈ borrower (t.customer_name = s.customer_name)
∧ βˆƒ u ∈ depositor (t.customer_name = u.customer_name) }

 Resulting relation:

Customer name
John
Emma

The query retrieves the names of customers who appear in both borrower and depositor relations, meaning they have both a loan and an account.

Example 4: Find the names of all customers having a loan at the "ABC" branch.  

{ t[customer-name] | βˆƒ s ∈ borrower (t[customer-name] = s[customer-name]) ∧ βˆƒ u

∈ depositor (t[customer-name] = u[customer-name]) }

Resulting relation: 

Customer name
John

Query retrieves the names of customers who have a loan (via borrower relation) and are linked to the specified branch, returning customers like Saurabh.

Key Concepts:

  • TRC does not specify execution steps, only the condition of result.
  • It focuses on what to retrieve, not how.
  • Based on variables, predicates, and quantifiers.
  • More theoretical, often used in database theory, formal methods, and GATE questions.

Comparison: TRC vs Relational Algebra

Feature

TRC

Relational Algebra

Type

Non-procedural

Procedural

Focus

What to retrieve

How to retrieve

Expression Style

Logical expressions

Set-based operators

Execution

Abstract, not directly executable

Directly convertible to query

Use in DBMS

Theoretical foundation

Basis for query execution

Important Points to Remember:

  • TRC is declarative: Describes result conditions, not how to get them.
  • Uses tuple variables referring to rows.
  • Allows quantifiers and logic operators for flexible querying.
  • Similar to mathematical set notation.
  • Does not include built-in operators like SQL or Relational Algebra.
  • Each TRC query defines a set of tuples satisfying given predicates.
  • Safer queries (domain-independent) always produce meaningful results regardless of database size or content.
Comment
Article Tags:
Article Tags:

Explore