Relational Calculus Query.
Relational Calculus Query
It is a non-procedure query language used to retrieve records from relations. In this type of language we do not specify the procedure to retrieve the records as we specify in relational algebra.In this language we simply specify the description along with the conditions. Consider the following example:
Relational Algebra:
Select all the employees with their details if sales is more quota.
The same statement can be stated as in Relational calculus as follow:
Get all employee such that their sales is more than quota .
Based on relational calculus various languages has been design such as LISP (List Processor), PROLOG and other language used in artificial intelligence.
Relational calculus has been divided into following two categories;
1. Tuple Relational Calculus
2. Domain Relation Calculus
Tuple Relational Calculus:
A tuple relational calculus is rational calculus which is based on tuples of a relations.
Example:
Get all employee if these sales is more than quota.
Example:
{t | t ϵ salesrep ^ t.sales > t.quota}
or
σsales > quota (salesrep)
Thus tuple relational calculus formally can be define as :
{t | (p) is true} , 'is true' remains sometime silent.
Domain Relational Calculus:
A domain relational calculus is relational calculus which specify over different domain of relation where a domain is attributes of relations and it is specify as follow.
{ <d1, d2, d3, ......> / p(di)}
Example:
Get employee with their id, name, date of birth , date of join , sales and quota if sales > quota.
{< emp_id, name, dob, doj, sales, quota> /
<emp_id, name, dob, doj , sales, quota> ^ sales > quota }
Comments
Post a Comment