0% found this document useful (0 votes)
17 views5 pages

Relational Calculus

Relational calculus is a non-procedural query language that specifies what to do without detailing how to do it. It includes Tuple Relational Calculus (TRC) for selecting tuples based on conditions and Domain Relational Calculus (DRC) for using attribute domains with logical connectives. Examples of queries demonstrate how to retrieve specific data from a Student table using both TRC and DRC notations.

Uploaded by

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

Relational Calculus

Relational calculus is a non-procedural query language that specifies what to do without detailing how to do it. It includes Tuple Relational Calculus (TRC) for selecting tuples based on conditions and Domain Relational Calculus (DRC) for using attribute domains with logical connectives. Examples of queries demonstrate how to retrieve specific data from a Student table using both TRC and DRC notations.

Uploaded by

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

Relational Calculus:

o Relational calculus is a non-procedural query language. In the


non-procedural query language, the user is concerned with the
details of how to obtain the end results.
o The relational calculus tells what to do but never explains how
to do.

Types of Relational Calculus:


1. Tuple Relational Calculus (TRC):
o The tuple relational calculus is specified to select the tuples in a
relation. In TRC, filtering variable uses the tuples of a relation.
o The result of the relation can have one or more tuples.

Notation: {T | P (T)} or {T | Condition (T)}

Where

T is the resulting tuples

P(T) is the condition used to fetch T.

For Example:
Table: Student

First_Name Last_Name Age


---------- --------- ----
Ajeet Singh 30
Chaitanya Singh 31
Rajeev Bhatia 27
Carl Pratap 28

Lets write relational calculus queries.


1.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

2.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
2. Domain Relational Calculus (DRC):
o The second form of relation is known as Domain relational
calculus. In domain relational calculus, filtering variable uses
the domain of attributes.

calculus. It uses logical connectives ∧ (and), ∨ (or) and ┓ (not).


o Domain relational calculus uses the same operators as tuple

o It uses Existential (∃) and Universal Quantifiers (∀) to bind the


variable.

Notation: { a1, a2, a3, ..., an | P (a1, a2, a3, ... ,an)}

Where

a1, a2 are attributes


P stands for formula built by inner attributes

For Example:
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}

The symbols used for logical operators are: ∧ for AND, ∨ for OR
Note:

and ┓ for NOT.

Output:

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

You might also like