Tuple Relational Calculus in DBMS [GATE Notes]
By BYJU'S Exam Prep
Updated on: September 25th, 2023
Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC) are both formal languages used to specify queries on a relational database. They are nonprocedural languages that operate on a set of tuples (rows) in one or more relations (tables) and return a set of tuples that satisfy a given condition. The main difference between Tuple Relational Calculus and Domain Relational Calculus is the way they express queries. Tuple Relational Calculus expresses queries in terms of logical formulas using variables to refer to tuples and conditions to restrict the result set, while DRC expresses queries in terms of domain variables and quantifiers, which are used to specify constraints on the tuples that should be returned.
Tuple Relational Calculus is based on the concept of firstorder logic and is similar to predicate calculus, whereas Domain Relational Calculus is based on the concept of secondorder logic and is similar to setbuilder notation in mathematics. Let us see the important concepts related to Tuple Relational Calculus and prepare it well for the upcoming GATE CSE exam.
Table of content
Tuple Relational Calculus in DBMS
Tuple Relational Calculus (TRC) is a formal language used to specify queries on a relational database. It is a nonprocedural language that operates on a set of tuples (rows) in one or more relations (tables) and returns a set of tuples that satisfy a given condition. TRC expresses queries in terms of logical formulas, using variables to refer to tuples and conditions to restrict the result set. The variables can be constrained using selection and projection operators, and the conditions can be combined using logical operators such as AND, OR, and NOT.
 A tuple relational calculus is a nonprocedural query language that specifies to select the tuples in a relation.
 It can select the tuples with a range of values or tuples for certain attribute values etc.
 The resulting relation can have one or more tuples.
 It uses firstorder Logic to generate the result.
 All the conditions used in the tuple expression are called a wellformed formula – WFF.
 All the conditions in the expression are combined by using logical operators like AND, OR, and NOT, and quantifiers like ‘For All’ (?) or ‘there exists’ (?).
 If the tuple variables are all bound variables in a WFF is called a closed WFF.
 In an open WFF, we will have at least one free variable.
Tuple Relational Query
A tuple relational query (TRQ) is a query language used to retrieve data from a relational database. It operates on a set of tuples (rows) in one or more relations (tables) and returns a set of tuples that meet the specified criteria.
TRQ is a declarative language, meaning that the user specifies what data they want and the database management system (DBMS) determines how to retrieve it. TRQ has a similar syntax to SQL (Structured Query Language), but the main difference is that TRQ operates on individual tuples rather than on sets of tuples.

{t  P (t)} or {t  condition (t)} — this is also known as expression of relational calculus

Where t is the resulting tuples, P(t) is the condition used to fetch t.
 P(t) is the firstorder predicate logic to set the condition, and t is the tuple variable.
Tuple Variables
There are basically two types of tuple variables
 Free Variables: Any tuple variable without any ‘For All’ or ‘there exists’ condition is called Free Variable in C. In a simple manner, we can say that if the tuple variable is not bounded to quantifiers, then it is said to be a free variable.
Example:{t  EMPLOYEE (t) AND t.DEPT_ID = 10} – this selects all the tuples of employee names who work for Department 10.
 Bounded Variables: Any tuple variable with the ‘For All’ or ‘there exists’ condition is called Bounded Variable. In a simple manner, we can say that if the tuple variable is bounded to quantifiers, then it is said to be a bounded variable.
Example: {t  EMPLOYEE (t) and t.SALARY>10000} – implies that it selects the tuples from EMPLOYEE relation such that resulting employee tuples will have salaries greater than 10000. This is an example of selecting a range of values.
Unsafe Query
A TRC Query with an infinite set of tuples in the result is said to be an unsafe query. the reason for a query being unsafe is basically the use of a universal tuple variable. The domain of the universal tuple variable is not restricted to the relation for which it is getting used.
Example:{t t ∉ Student} this query will result in all the tuples which are not part of the student table which are infinite. hence the query is unsafe.
Domain Relational Calculus(DRC)
As compared to tuple relational calculus, domain relational calculus makes use of the list of attributes that needs to be selected from the relation based on the condition. Domain relational calculus is the same as tuple relational calculus it only differs in the way of selecting the attributes instead of selecting whole tuples. It is denoted as below:
{< a_{1}, a_{2}, a_{3}, … a_{n} >  P(a_{1}, a_{2}, a_{3}, … a_{n})}
Where a_{1}, a_{2}, a_{3}, … a_{n} are attributes of the relation and P is the condition.
For e.g.: Select the EMP_NAME and EMP_ID of employees who work for Department 12
{
Other concepts of Tuple Relational Calculus like a free variable, bound variable, WFF, etc. remain the same in Domain Relational Calculus too. The only difference is Domain Relational Calculus is based on attributes of the relation.
Tuple Relational Calculus Examples
Tuple Relational Calculus (TRC) is a query language that is used to retrieve data from a relational database by specifying conditions that the desired tuples must satisfy. Here are a few examples of Tuple Relational Calculus:
 Retrieve all the employees who work in the Sales department.: {t  Employee(t) ∧ t.department = Sales}
 Retrieve the names of all the employees who earn more than $50,000.: {t.name  Employee(t) ∧ t.salary > 50000}
 Retrieve the names of all the employees who work in the Sales department and earn more than $50,000.: {t.name  Employee(t) ∧ t.department = Sales ∧ t.salary > 50000}
Other Important GATE Topics  
2’s Complement  Data Hazard 
Floating Point Representation  Asynchronous Counter 
Userdefined Data Types in C  Full Subtractor 