Open In App

Domain Relational Calculus in DBMS

Last Updated : 28 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Domain Relational Calculus (DRC) is a non-procedural query language used to retrieve information from a relational database. It is based on predicate logic and allows the user to specify what data they want to retrieve, but not how to retrieve it, making it a declarative query language.

Domain Relational Calculus (DRC)

Domain Relational Calculus (DRC) is a formal query language for relational databases. It describes queries by specifying a set of conditions or formulas that the data must satisfy. These conditions are written using domain variables and predicates, and it returns a relation that satisfies the specified conditions.

A general form of a DRC query is written 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.

The query returns a relation where each tuple consists of values for the domain variables x1,x2,…,xn such that the predicate PPP is true.

Key Characteristics of DRC:

  • Non-procedural: Specifies what data to retrieve without describing the steps for retrieval.
  • Based on Predicate Calculus: Utilizes logical expressions (predicates) to describe the query.
  • Relational Database Queries: Primarily used for querying relational databases.

Components of Domain Relational Calculus (DRC)

1. Domain Variables

Domain variables represent the attributes (fields) that will appear in the resulting relation of the query. These variables are the placeholders that will hold the actual values in the result.

2. Predicate

A predicate is a logical condition or formula that the data must satisfy. It is expressed using comparison operators, connectives, and quantifiers.

  • Comparison operators: =, >, <, >=, <=, !=.
  • Connectives: AND, OR, NOT.
  • Quantifiers: FOR ALL, EXISTS.

3. Quantifiers

Quantifiers are used to express the scope of a query:

  • Existential quantifier (): Denotes that there exists at least one instance that satisfies a condition.
  • Universal quantifier (): Denotes that all instances in the domain satisfy a condition.

4. Domains and Relations

A domain refers to a specific set of values (like integers, strings) that a variable can take. A relation is a table in the database, and the tuples in the relation represent data that matches the query conditions.

Writing Queries in Domain Relational Calculus (DRC)

Writing a query in DRC involves describing the desired result by specifying the domain variables and predicates that define the conditions the data must meet. Below are examples:

Table 1: Customer

Customer NameStreetCity
DebomitKadamtalaAlipurduar
SayantanUdaypurBalurghat
SoumyaNutanchatiBankura
RituJuhuMumbai

Table 2: Loan

Loan NumberBranch NameAmount
L01Main200
L03Main150
L10Sub90
L08Main60

Table 3: Borrower

Customer NameLoan Number
RituL01
DebomitL08
SoumyaL03

Example 1: Finding Loans with Amount >= 100

To find all loans with an amount greater than or equal to 100, we use the following query in DRC:


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

Resulting relation:

Loan NumberBranch NameAmount
L01Main200
L03Main150

This query specifies that the result will contain the loan number (l), branch name (b), and amount (a) from the loan relation where the amount is greater than or equal to 100.

Example 2: Finding Loan Numbers >= 150

To find loan numbers where the amount is greater than or equal to 150, we write:

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

Resulting Relation:

Loan Number
L01
L03

Example 3: Finding Customers with Loans from "Main" Branch

To find the names of customers who have a loan at the "Main" branch, along with their loan amounts:

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

Resulting relation:

Customer NameAmount
Ritu200
Debomit60
Soumya150

Advantages of Domain Relational Calculus (DRC)

  1. Declarative Nature: DRC allows the user to describe what data they need without having to specify how to retrieve it. This makes it easier to write queries and understand them.
  2. Mathematical Foundation: Being based on predicate logic, DRC provides a solid theoretical foundation for relational databases.
  3. Non-Procedural: Unlike procedural query languages, DRC focuses on describing the result, not the procedure to get it.
  4. Flexible and Powerful: It supports complex queries involving multiple relations, predicates, and conditions.

Limitations of Domain Relational Calculus (DRC)

  1. Complexity: DRC can be difficult to use for complex queries due to its reliance on logical formulas. It requires a good understanding of predicate calculus.
  2. No Specification of Query Execution: Since it is non-procedural, DRC does not specify how queries should be executed, which can sometimes lead to inefficiencies in query execution.
  3. Lack of Optimization: Unlike SQL, DRC does not provide built-in optimization mechanisms, meaning that users must rely on the DBMS for query optimization.
  4. Less User-Friendly: As a formal query language, DRC is not as user-friendly as SQL, which is more widely used and has a simpler syntax.

DRC vs TRC (Tuple Relational Calculus) Comparison

Aspect

Domain Relational Calculus

Tuple Relational Calculus

Query Focus

Focuses on domain variables (attributes)

Focuses on tuple variables (rows)

Syntax

Describes queries using domain variables and predicates

Describes queries using tuple variables and predicates

Usage

More abstract; deals with individual attributes

Deals with entire rows (tuples) in a relation

Query Writing Style

Less intuitive; requires logical expressions involving attributes

More intuitive; uses variables representing tuples

Complexity

Can be more complex due to the abstraction of variables

Simpler to understand and write compared to DRC

While both DRC and TRC are non-procedural query languages that allow users to query relational databases, DRC focuses on individual attributes (domain variables), while TRC focuses on tuples (rows). TRC is more widely used because it is more intuitive and easier to understand.


Next Article
Article Tags :

Similar Reads