# Tuple Relational Calculus (TRC) in DBMS

• Difficulty Level : Easy
• Last Updated : 30 Nov, 2021

Tuple Relational Calculus is a non-procedural query language unlike relational algebra. Tuple Calculus provides only the description of the query but it does not provide the methods to solve it. Thus, it explains what to do but not how to do.
In Tuple Calculus, a query is expressed as

`{t| P(t)}`

where t = resulting tuples,
P(t) = known as Predicate and these are the conditions that are used to fetch t

Thus, it generates set of all tuples t, such that Predicate P(t) is true for t.

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.

Example:
Table-1: Customer

Table-2: Branch

Table-3: Account

Table-4: Loan

Table-5: Borrower

Table-6: Depositor

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

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

Resulting relation:

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

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

```{t| ∃ s ∈ loan(t[loan number] = s[loan number]
∧ s[amount]>=10000)}```

Resulting relation:

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

```{t | ∃ s ∈ borrower( t[customer-name] = s[customer-name])
∧  ∃ u ∈ depositor( t[customer-name] = u[customer-name])}```

Resulting relation:

Queries-4: Find the names of all customers having a loan at the “ABC” branch.

```{t | ∃ s ∈ borrower(t[customer-name] = s[customer-name]
∧ ∃ u ∈  loan(u[branch-name] = “ABC” ∧ u[loan-number] = s[loan-number]))}```

Resulting relation:

My Personal Notes arrow_drop_up
Related Articles