A non-procedural query language called relational calculus is used to retrieve data from relational databases. Thanks to this mathematical based system, users can describe what they want to retrieve from a database without specifying how to do so.
Note: There are two types of quantifiers:
- Universal Quantifiers: The universal quantifier, denoted by ∀, is read as for all, which denotes that in a given set of tuples, precisely all tuples satisfy a particular condition.
- Existential Quantifiers: The existential quantifier denoted by ∃ is read as for all, indicating that there is at least one instance in a given set of tuples whose value satisfies a particular condition.
Relational Calculus exists in two forms:
- Tuple Relational Calculus (TRC)
- Domain Relational Calculus (DRC)
Tuple Relational Calculus (TRC):
Data from relational databases can be retrieved using the non-procedural query language tuple relational calculus (TRC). Users can describe what they want to retrieve from a database without stating how to do so thanks to this system, which is based on the idea of sets of tuples.
{T | P (T)} or {T | Condition (T)}
Where
T is the resulting tuples
P(T) is the condition used to fetch T.
For instance,
{ T.name | Batch(T) AND T.roll = 126 }
Output:
This query selects the tuples from the Batch relation. It returns a tuple with ‘name’ from Batch whose roll number is 126.
Domain Relational Calculus (DRC):
Domain relational calculus is the name for the second type of relation. The domain of attributes is used by the filtering variable in domain relational calculus. The same operators in tuple calculus are also used in domain relational calculus. It makes use of the logical connectives (and), (or), and (not). The variable is bound using existential () and universal quantifiers (). A query language related to domain relational calculus is called QBE, or Query by Example.
The Domain relational calculus expression syntax:
{<x1,x2,x3,x4...> \| P(x1,x2,x3,x4...)}
where,
<x1,x2,x3,x4…> are domain variables used to get the column values required, and P(x1,x2,x3…) is a predicate expression or condition.
For example:
{< name, roll, marks > | ∈ Result ∧ subject = 'database'}
Output:
This query will yield the name, roll, and marks from the relation Result, where the subject is database.
Note: also read about What is Relational Algebra?
Follow Me
Please follow me to read my latest post on programming and technology if you like my post.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Leave a Comment