### 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 calculusWhere 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:

{< 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 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:

## Click Here to Avail GATE CSE Test Series!(100+ Mock Tests)

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**

## Comments

write a commentSanjay Kumar BhartiMay 26, 2018

Mayank PrakashApr 29, 2019

Payal SagarSep 30, 2019

:)

srinivas PDec 6, 2019

which documents are we need to write a gate exam in center( like,admit card and adhar card ) is there nay other documents are required or not

plss tell me i'm confused.

i'm completed b.tech 2019

...Read More