/    /  DBMS – Tuple Relational Calculus

## Tuple Relational Calculus:

This is a ‘non-procedural query language’, whereas ‘Relational Algebra’ is a ‘procedural query language’.

The TRC describes the desired information without giving a specific procedure for obtaining the result.

The query expression in this language is :

{ t / P(t) }

Consider the following relation:

R1 :  FACULTY-1

 FNo FName DNo Qual Salary 22 Riya 21 Ph.D 55000 24 Priya 22 M. Tech 50000 25 Zayn 22 M. Tech 42000 27 Harry 23 M. Tech 28000 30 Sia 23 M. Tech 32000 33 Max 24 Ph.D 53000 35 Fred 24 Ph.D 52000 37 Diva 25 M. Tech 26000 39 Ben 25 M. Tech 24000 40 Trent 25 M. Tech 34000

Example-1 : Find the Faculty No, Faculty name, DNo, Qual and salaries of all the faculty, who are drawing more than 30000.

{ t / t ϵ  Faculty-1  ˄  t[Salary] > 30000 }

Output :

 FNo FName DNo Qual Salary 22 Riya 21 Ph.D 55000 24 Priya 22 M. Tech 50000 25 Zayn 22 M. Tech 42000 30 Sia 23 M. Tech 32000 33 Max 24 Ph.D 53000 35 Fred 24 Ph.D 52000 40 Trent 25 M. Tech 34000

Example-2 : Find the Faculty No and Faculty name of all the faculty, who are drawing more than 40000.

{ t / Ǝ s ϵ  Faculty-1  ( t[FNo] = s[FNo] ˄

t[ FName] = s{FName]  ˄  s[Salary] > 40000 }

Output :

 FNo FName 22 Riya 24 Priya 25 Zayn 33 Max 35 Fred

Example-3 : Find the names of students who are studying in departments.

{ t / Ǝ s ϵ  STUD  ( t[SName] = s[SName] ˄

Ǝ u ϵ  DEPT ( s[DNo] = u[DNo]  ˄  u[DName] = ‘IT’ ) ) }

Consider the following relations :

 R1 :  STUD R2 : DEPT SNo SName DNo DNo DName 21 Riya 21 21 CSE 23 Priya 21 22 IT 26 Zayn 22 23 ECE 28 Harry 22 24 ME 30 Sia 23 25 EEE

Output :     SName

Zayn

Harry

Example-4 : Find the name of the department where ‘pqr’ is studying.

{ t / Ǝ s ϵ DEPT  ( t[DName] = s[DName] ˄

Ǝ u ϵ  STUD ( s[DNo] = u[DNo]  ˄  u[SName] = ‘pqr’ ) ) }

Output :      DName

CSE