# Tuple Relational Calculus And Domain Relational Calculus Study Notes for GATE CS Engineering Exams

By Mukesh Kumar|Updated : September 30th, 2021

### Tuple Relational Calculus(TRC)

• A tuple relational calculus is a non procedural query language which specifies to select the tuples in a relation.
• It can select the tuples with range of values or tuples for certain attribute values etc.
• The resulting relation can have one or more tuples.
• It uses first order Logic to generate the result.
• All the conditions used in the tuple expression are called as well formed 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 closed WFF.
• In an open WFF, we will have at least one free variable.

### Tuple Relational Calculus(TRC)

• A tuple relational calculus is a non procedural query language which specifies to select the tuples in a relation.
• It can select the tuples with range of values or tuples for certain attribute values etc.
• The resulting relation can have one or more tuples.
• It uses first order Logic to generate the result.
• All the conditions used in the tuple expression are called as well formed 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 closed WFF.
• In an open WFF, we will have at least one free variable.

### Tuple relational Query

• {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 first-order 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 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 ‘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 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:

{< a1, a2, a3, … an > | P(a1, a2, a3, … an)}

Where a1, a2, a3, … an are attributes of the relation and P is the condition.

For e.g.: Select EMP_NAME and EMP_ID of employees who work for department 12

{<EMP_ID, EMP_NAME> | <EMP_ID, EMP_NAME> ? EMPLOYEE Λ DEPT_ID = 12}

Other concepts of Tuple Relational Calculus like a free variable, bound variable, WFF etc. remains the same in Domain Relational Calculus too. The only difference is Domain Relational Calculus is based on attributes of the relation.

Candidates can also practice 110+ Mock tests for exams like GATE, NIELIT with the BYJU'S Exam Prep Test Series check the following link:

Get unlimited access to 21+ structured Live Courses all 112+ mock tests with Online Classroom Program for GATE CS & PSU Exams:

## Click here to avail Online Classroom Program for Computer Science Engineering

Thanks

#DreamStriveSucceed

Posted by: Member since Feb 2020  GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com