Tupple Relational Calculus is a **non-procedural query language** unlike relational algebra. Tupple 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 Tupple Calculus, a query is expressed as

{t| P(t)}

where t = resulting tupples,

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

Thus, it generates set of all tupples 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**

Customer name | Street | City |
---|---|---|

Saurabh | A7 | Patiala |

Mehak | B6 | Jalandhar |

Sumiti | D9 | Ludhiana |

Ria | A5 | Patiala |

**Table-2: Branch**

Branch name | Branch city |
---|---|

ABC | Patiala |

DEF | Ludhiana |

GHI | Jalandhar |

**Table-3: Account**

Account number | Branch name | Balance | |
---|---|---|---|

1111 | ABC | 50000 | |

1112 | DEF | 10000 | |

1113 | GHI | 9000 | |

1114 | ABC | 7000 |

**Table-4: Loan**

Loan number | Branch name | Amount |
---|---|---|

L33 | ABC | 10000 |

L35 | DEF | 15000 |

L49 | GHI | 9000 |

L98 | DEF | 65000 |

**Table-5: Borrower**

Customer name | Loan number |
---|---|

Saurabh | L33 |

Mehak | L49 |

Ria | L98 |

**Table-6: Depositor**

Customer name | Account number |
---|---|

Saurabh | 1111 |

Mehak | 1113 |

Sumiti | 1114 |

**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:

Loan number | Branch name | Amount |
---|---|---|

L33 | ABC | 10000 |

L35 | DEF | 15000 |

L98 | DEF | 65000 |

In the above query, t[amount] is known as tupple 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:

Loan number |
---|

L33 |

L35 |

L98 |

**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:

Customer name |
---|

Saurabh |

Mehak |

**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:

Customer name |
---|

Saurabh |

## leave a comment

## 0 Comments