×

DBMS Tutorial

DBMS Practice

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 AddressCity
RaghavA23/B6Mumbai
Sameer567/453Delhi
Sujata543/27Kanpur
ShivaniD35Jaipur
AmarB82/78Kolkata

Table 2: Company

Company City
WiproChennai
AccentureDelhi
InfosysBangalore

Table 3: Salary

Engineer Name CompanySalary
RaghavWipro24,000
SameerInfosys23,000
SujataAccenture25,000
ShivaniWipro27,000
AmarAccenture30,000

Table 4: Incentive + Bonus

CompanyIncentive + Bonus
Wipro4,000
Accenture5,000
Infosys7,000

Table 5: Salary (Included Incentive + Bonus)

Engineer Name CompanySalary
RaghavWipro28,000
SameerInfosys30,000
SujataAccenture30,000
ShivaniWipro31,000
AmarAccenture35,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
SujataAccenture25,000
ShivaniWipro27,000
AmarAccenture30,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


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.