Tuple Relational Calculus in DBMS

Tuple Relational Calculus in DBMS

 

In this article, we will learn about Tuple Relational Calculus in DBMS.

  • Relational algebra specifies procedures and methods to fetch data hence is called as a procedural query language ,whereas relational calculus is a non procedural query language focuses on just fetching data rather than how the query will work and how data will be fetched 
  • Simply relational calculus is nothing but focusing on what to do rather than focusing on how to do 

Relational calculus is present in two formats 

  • Tuples relational calculus(TRC) 
  • Domain relational calculus(DRC)
Tuple Relational Calculus in DBMS

Tuple Relational Calculus (TRC) in DBMS 

Relational calculus peoples are filtered based on a condition 

Syntax:

{ T | Condition } 

 

Relation part 

  • Here t represents the tuple variable which is nothing but representing that it is a table 
  • It can be any variable but for understanding we use variable t which stands for the table as per our context
  • For example, if our table is Student, we would put it as Student(T)

 

Condition part 

Condition is specified using this dot variable the common and column we need to operate

Example  1

T.age > 22
  • where T is our tuple variable and age is a column that is used for filtering the records in the relation 
  • Now combine both relational and conditional part and see how the final quotation will look like T.name | Student(T) AND T.age > 21 
  • It is a relational calculus which results in names of students from the table student for having age greater than 17 

Example 2 

{t | Employee (e) and e.SALARY > 100000} 
  • Now, this represents results which will be returned as tuple t.
  • Predicate here is – Employee (e) and e.SALARY > 100000 will return tuples for all the employees who have a salary greater than 100000. 

Example 3 

{ t | Employee (e) and Salary(t.emp_ID = s.emp_ID ∧ s.Salary >= 100000)} 
  • It will result in the employeeId for each employee that has his/her salary  greater or equal to 10000.
Learn more about DBMS here on this page.