# Tuple Relational Calculus | DBMS

**DBMS Tuple relational calculus**: In this article, we are going to learn about the **tuple relational calculus in Database management system**, its query notation, examples, etc.

Submitted by Anushree Goswami, on August 09, 2019

**Tuple Relational Calculus** is a non-procedural and declarative query language. The declarative query procedure gives logical condition which is required to be satisfied by the results. In the non-procedural query language, the user always tries to find out the details of how to get the results. Tuple Relational Calculus explains what to do by describing query but not explain how to do by does not provide the methods to solve.

**Tuple Relational Calculus** in a relation is specified in the selection of tuples with details. In relation, the tuples are used by filtering variables. The result which comes out as a resultant relation can have one or more than one tuples in a resultant relation. It is easy to use by someday who is not a skilled person also. Tuple variable which integrated with a relation is called the range relation.

In Tuple Calculus, the notation of a query is:

{T | P (T)} or {T | Condition (T)}

Where,

**T**= resulting tuples,**P(T)**= called as Predicate and It is a condition which is used to fetch**T**.

**Example**

**Table 1: Engineer**

Engineer Name | Address | City |
---|---|---|

Raghav | A23/B6 | Mumbai |

Sameer | 567/453 | Delhi |

Sujata | 543/27 | Kanpur |

Shivani | D35 | Jaipur |

Amar | B82/78 | Kolkata |

**Table 2: Company**

Company | City |
---|---|

Wipro | Chennai |

Accenture | Delhi |

Infosys | Bangalore |

**Table 3: Salary**

Engineer Name | Company | Salary |
---|---|---|

Raghav | Wipro | 24,000 |

Sameer | Infosys | 23,000 |

Sujata | Accenture | 25,000 |

Shivani | Wipro | 27,000 |

Amar | Accenture | 30,000 |

**Table 4: Incentive + Bonus**

Company | Incentive + Bonus |
---|---|

Wipro | 4,000 |

Accenture | 5,000 |

Infosys | 7,000 |

**Table 5: Salary (Included Incentive + Bonus)**

Engineer Name | Company | Salary |
---|---|---|

Raghav | Wipro | 28,000 |

Sameer | Infosys | 30,000 |

Sujata | Accenture | 30,000 |

Shivani | Wipro | 31,000 |

Amar | Accenture | 35,000 |

**Query 1:** Find the Engineer Name, Company and Salary of those whose salaries are greater than 23,000 excluded Incentive + Bonus.

{T| T ∈ Engineer ∧ T [Salary]>= 23,000}

**The Resultant relation is:**

Engineer Name | Company | Salary |
---|---|---|

Raghav | Wipro | 24,000 |

Sujata | Accenture | 25,000 |

Shivani | Wipro | 27,000 |

Amar | Accenture | 30,000 |

In the above query, The T [Salary] is called as Tuple variable.

**Query 2:** Find the Engineer Name of all the Company whose salaries are less than 27,000 excluded Incentive + Bonus.

{T| ∃ S ∈ Engineer ( T[Company] = S[Company] ∧ S [Salary]< 27,000)}

**The Resultant relation is:**

Engineer Name |
---|

Raghav |

Sameer |

Sujata |

**Query 3:** Find the Engineer Name of those who works in Accenture and their cities are Kanpur and Kolkata.

{T| ∃ S ∈ Engineer (T [Engineer Name]) = S[Engineer Name]) ∧∃ U ∈ Salary (T [Engineer Name] = U [Engineer Name])}

**The Resultant relation is:**

Engineer Name |
---|

Sujata |

Amar |

**Query 4:** Find the Engineer Name of those whose salaries included incentive + Bonus is "30,000" and their cities are Delhi and Kanpur.

{T | ∃ S ∈ Engineer (T [City] = S[City] ∧ ∃ U ∈ Salary(Included Incentive + Bonus)(U[Salary] = "30,000" ∧ U[Engineer Name] = S[Engineer Name] ) ) }

**The Resultant relation is:**

Engineer Name |
---|

Sameer |

Sujata |

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.