# The Domain Relational Calculus

Posted By on October 6, 2014

# The Domain Relational Calculus

1. Domain variables take on values from an attribute’s domain, rather than values for an entire tuple.

## Formal Definitions

1. An expression is of the form

where the represent domain variables, and is a formula.

2. An atom in the domain relational calculus is of the following forms
• where is a relation on attributes, and , are domain variables or constants.
• , where and are domain variables, and is a comparison operator.
• , where c is a constant.
3. Formulae are built up from atoms using the following rules:
• An atom is a formula.
• If is a formula, then so are and .
• If and are formulae, then so are , and .
• If is a formula where x is a domain variable, then so are and .

## Example Queries

1. Find branch name, loan number, customer name and amount for loans of over \$1200.
2. Find all customers who have a loan for an amount > than \$1200.
3. Find all customers having a loan from the SFU branch, and the city in which they live.
4. Find all customers having a loan, an account or both at the SFU branch.
5. Find all customers who have an account at all branches located in Brooklyn.

If you find this example difficult to understand, try rewriting this expression using implication, as in the tuple relational calculus example. Here’s my attempt:

I’ve used two letter variable names to get away from the problem of having to remember what stands for.

## Safety of Expressions

1. As in the tuple relational calculus, it is possible to generate infinite expressions. The solution is similar for domain relational calculus-restrict the form to safe expressions involving values in the domain of the formula.

## Expressive Power of Languages

1. All three of the following are equivalent:
• The relational algebra.
• The tuple relational calculus restricted to safe expressions.
• The domain relational calculus restricted to safe expressions.

#### Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby

Website: http://world4engineers.com