Domain Relational Calculus in DBMS


Database management systems (DBMS) employ the non−procedural query language known as Domain Relational Calculus (DRC). DRC focuses simply on what data to collect without outlining the techniques for retrieval, as opposed to Relational Algebra, which provides methods and procedures for fetching data. It offers a declarative method of database querying.

Syntax

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

Here,

<x1, x2, ..., xn> refers to the resulting domain variable

P(x1, x2, ..., xn) refers to the condition equivalent to the predicate calculus.

Example 1

This example shows us to solve the query which is how to find the names of students who are 20 years old from the given table.

Students

ID	 Name	    Age
1	 John	    20
2	 Sarah	    22
3	 Emily	    19
4	 Michael	21

DRC Expression

 {<Name> | $\exists$ ID, Age (<ID, Name, Age> $\epsilon$ Students ∧ Age = 20)}

Output

Name
John

Example 2

This example shows us to solve the query which is to find the names of employees who work in the IT department and earn more than $55,000 from the given table.

Employee

ID	 Name	    Department	    Salary
1	 Alice	    HR	            50000
2	 Bob	    IT              60000
3	 Claire	    Finance	        55000
4	 David	    IT	            65000

DRC Expression

 {<Name> | $\exists$ ID, Department, Salary (<ID, Name, Department, Salary> $\epsilon$ Employees ∧ Department = "IT" ∧ Salary > 55000)}

Output

Name
Bob
David

Expressive Power of Domain Relational Calculus

Equivalence with Tuple Relational Calculus

When restricted to safe expressions, Domain Relational Calculus is equivalent in expressive power to Tuple Relational Calculus. Safe expressions in DRC produce a finite number of values within the domain of the expression.

Extending DRC to Support Aggregation, Grouping, and Ordering

While Domain Relational Calculus, as a standalone language, is unable to express aggregation, grouping, and ordering operations, it can be extended to support these functionalities in conjunction with other query languages or extensions.

While Domain Relational Calculus, as a standalone language, is unable to express aggregation, grouping, and ordering operations, it can be extended to support these functionalities in conjunction with other query languages or extensions.

Applications of Domain Relational Calculus

Declarative Approach to Querying: Database querying may be done declaratively using Domain Relational Calculus. Users may concentrate on specifying the needed data without having to worry about the specifics of how the query is carried out.

Simplifying Complex Queries: By offering a clear and organized syntax, DRC makes constructing complicated queries easier. Users may logically and clearly state their query requirements by utilizing domain variables and filtering criteria.

Supporting Data Manipulation and Retrieval: In addition to supporting data querying, Domain Relational Calculus may also enable data manipulation operations including insertions, removals, and updates. Users may efficiently obtain and alter data thanks to its expressive capability.

Conclusion

This article consists of domain relational calculus in dbms which refers to the non−procedural query language used in the field of dbms. Examples are used to explain the DRC with the syntax provided. The expressive power of domain relational calculus is equivalence with tuple relational calculus, and extending DRC to support aggregation, grouping, and ordering. Applications for domain relational calculus are declarative approaches to querying, simplifying complex querying, and supporting data manipulation and retrieval.

Updated on: 14-Jul-2023

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements