Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

UNIT-1

CHAPTER 1.3
Lecture-3.4 (Domain Relational Calculus)

Domain Relational Calculus in DBMS

In the tuple relational calculus, you have use variables that have a series of tuples in a
relation. In the domain relational calculus, you will also use variables, but in this case, the
variables take their values from domains of attributes rather than tuples of relations. A
domain relational calculus expression has the following general format:

{d1, d2, . . . , dn | F(d1, d2, . . . , dm)} m ≥ n

where d1, d2, . . . , dn, . . . , dm stand for domain variables and F(d1, d2, . . . , dm) stands for
a formula composed of atoms.

Example:

select TCHR_ID and TCHR_NAME of teachers who work for department 8, (where suppose
- dept. 8 is Computer Application Department)

{<tchr_id, tchr_name=""> | <tchr_id, tchr_name=""> ? TEACHER Λ DEPT_ID = 10}

Get the name of the department name where Karlos works:

{DEPT_NAME |< DEPT_NAME > ? DEPT Λ ? DEPT_ID ( ? TEACHER Λ TCHR_NAME


= Karlos)}

It is to be noted that these queries are safe. The use domain relational calculus is restricted to
safe expressions; moreover, it is equivalent to the tuple relational calculus, which in turn is
similar to the relational algebra.

Domain Relational Calculus is a non-procedural query language equivalent in power to


Tuple Relational Calculus. Domain Relational Calculus provides only the description of the
query but it does not provide the methods to solve it. In Domain Relational Calculus, a query
is expressed as,

{ < x1, x2, x3, ..., xn > | P (x1, x2, x3, ..., xn ) }

where, < x1, x2, x3, …, xn > represents resulting domains variables and P (x1, x2, x3, …,
xn ) represents the condition or formula equivalent to the Predicate calculus.
Predicate Calculus Formula:

1. Set of all comparison operators


2. Set of connectives like and, or, not
3. Set of quantifiers

Example:

Table-1: Customer

Customername Street City

Debomit Kadamtala Alipurduar

Sayantan Udaypur Balurghat

Soumya Nutanchati Bankura

Ritu Juhu Mumbai

Table-2: Loan

Loannumber Branchname Amount

L01 Main 200

L03 Main 150

L10 Sub 90

L08 Main 60

Table-3: Borrower

Customername Loannumber

Ritu L01

Debomit L08

Soumya L03

Query-1: Find the loan number, branch, amount of loans of greater than or equal to 100
amount.

{≺l, b, a≻ | ≺l, b, a≻ ∈ loan ∧ (a ≥ 100)}

Resulting relation:
Loan number Branch name Amount

L01 Main 200

L03 Main 150

Query-2: Find the loan number for each loan of an amount greater or equal to 150.

{≺l≻ | ∃ b, a (≺l, b, a≻ ∈ loan ∧ (a ≥ 150)}

Resulting relation:

Loan number

L01

L03

Query-3: Find the names of all customers having a loan at the “Main” branch and find the
loan amount .

{≺c, a≻ | ∃ l (≺c, l≻ ∈ borrower ∧ ∃ b (≺l, b, a≻ ∈ loan ∧ (b = “Main”)))}

Resulting relation:

Customer Name Amount

Ritu 200

Debomit 60

Soumya 150

OTHER REFRENCES

•    Domain Relational Calculus in DBMS - GeeksforGeeks

•     What is Relational Calculus - Computer Notes (ecomputernotes.com)

•     Relational Calculus in DBMS (w3schools.in)

SUGGESTED BOOK REFERENCES

1. C.J.Date, “An Introduction to DatabaseSystems”, Addison Wesley.


2. Thomas M. Connolly, Carolyn & E.Begg,“Database Systems: A Practical Approach
to Design, Implementationand Management”, 5/E, University of Paisley, Addison-
Wesley.
3. Rob,”Database Principal Fundamental Design, Cengage Learning.

You might also like