Domain Relational Calculus
This is a ‘non-procedural query language’, whereas ‘Relational Algebra’ is a ‘procedural query language’.
This language uses domain variables that take on values from an attributes domain, instead of the values for an entire tuple.
Formal Definition :
An expression in the DRC is of the form :
{ < x1, x2, …,xn > / P ( x1, x2, …, xn ) }
Here, < x1, x2, …,xn > ϵ r, where ‘r’ is a relation on ‘n’ attributes and x1, x2, …,xn are domain variables.
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.
{ < f, n, d, q, s > / < f, n, d, q, s > ϵ FACULTY-1 ˄ s > 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, Faculty name of all the faculty, who are drawing more than 40000.
{ < f , n > / < Ǝ d, q, s ( < f, n, d, q, s > ϵ FACULTY-1 ˄ s > 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 IT department.
{ < n > / Ǝ s, d (< s, n, d > ϵ STUD ˄ Ǝ m ( < d , m > ϵ DEPT˄ m = ‘IT’ ) }
Output :
SName |
Zayn |
Harry |
Example-4 : Find the name of the department where ‘pqr’ is studying.
{ < m > / Ǝ d ( <d,m> ϵ DEPT ˄ Ǝ s,n ( < s , n , d > ϵ STUD˄ n = ‘pqr’ ) }
Output :
DName |
CSE |
Reference Links