Home »
DBMS
Tuple Relational Calculus (TRC) in DBMS
DBMS | TRC: In this tutorial, we will learn about the Tuple Relational Calculus in the database management system, its query notation, and example.
By Anushree Goswami Last updated : May 31, 2023
What is Tuple Relational Calculus (TRC) in DBMS?
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.
Query Notation of Tuple Relational Calculus
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.
Tuple Relational Calculus (TRC) Example
Consider the below-given tables:
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 |