0% found this document useful (0 votes)
31 views4 pages

Relational Calculus in DBMS

Relational Calculus is a non-procedural query language that specifies what data to retrieve without detailing how to do so. It includes Tuple Relational Calculus (TRC), which selects tuples based on conditions, and Domain Relational Calculus (DRC), which filters records based on domains. The document provides examples of queries using both TRC and DRC with a Student table.

Uploaded by

mwendwanoelix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

Relational Calculus in DBMS

Relational Calculus is a non-procedural query language that specifies what data to retrieve without detailing how to do so. It includes Tuple Relational Calculus (TRC), which selects tuples based on conditions, and Domain Relational Calculus (DRC), which filters records based on domains. The document provides examples of queries using both TRC and DRC with a Student table.

Uploaded by

mwendwanoelix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DBMS Relational Calculus

In the previous tutorial, we discussed Relational Algebra which is a procedural query language.
In this tutorial, we will discuss Relational Calculus, which is a non-procedural query language.

What is Relational Calculus?


Relational calculus is a non-procedural query language that tells the system what data to be
retrieved but doesn’t tell how to retrieve it.

Types of Relational Calculus

1. Tuple Relational Calculus (TRC)


Tuple relational calculus is used for selecting those tuples that satisfy the given condition.
Table: Student

First_Name Last_Name Age


---------- --------- ----
Ajeet Singh 30
Chaitanya Singh 31
Rajeev Bhatia 27
Carl Pratap 28
Lets write relational calculus queries.
Query to display the last name of those students where age is greater than 30

{ t.Last_Name | Student(t) AND t.age > 30 }


In the above query you can see two parts separated by | symbol. The second part is where we
define the condition and in the first part we specify the fields which we want to display for the
selected tuples.

The result of the above query would be:

Last_Name
---------
Singh
Query to display all the details of students where Last name is ‘Singh’

{ t | Student(t) AND t.Last_Name = 'Singh' }


Output:

First_Name Last_Name Age


---------- --------- ----
Ajeet Singh 30
Chaitanya Singh 31

Exercise
2. Domain Relational Calculus (DRC)
In domain relational calculus the records are filtered based on the domains.
Again we take the same table to understand how DRC works.
Table: Student

First_Name Last_Name Age


---------- --------- ----
Ajeet Singh 30
Chaitanya Singh 31
Rajeev Bhatia 27
Carl Pratap 28
Query to find the first name and age of students where student age is greater than 27

{< First_Name, Age > | ∈ Student ∧ Age > 27}


Note:
The symbols used for logical operators are: ∧ for AND, ∨ for OR and ┓ for NOT.

Output:

First_Name Age
---------- ----
Ajeet 30
Chaitanya 31
Carl 28

Exercise

You might also like