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

FNoFNameDNoQualSalary
22Riya21Ph.D55000
24Priya22M. Tech50000
25Zayn22M. Tech42000
27Harry23M. Tech28000
30Sia23M. Tech32000
33Max24Ph.D53000
35Fred24Ph.D52000
37Diva25M. Tech26000
39Ben25M. Tech24000
40Trent25M. Tech34000

 

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 :

FNoFNameDNoQualSalary
22Riya21Ph.D55000
24Priya22M. Tech50000
25Zayn22M. Tech42000
30Sia23M. Tech32000
33Max24Ph.D53000
35Fred24Ph.D52000
40Trent25M. Tech34000

 

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 :

 

FNoFName
22Riya
24Priya
25Zayn
33Max
35Fred

 

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 :  STUDR2 : DEPT
SNoSNameDNoDNoDName
21Riya2121CSE
23Priya2122IT
26Zayn2223ECE
28Harry2224ME
30Sia2325EEE

 

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

 

Reference Link

Tuple Relational Calculus: