Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE) PDF Download

Tuple Relational Calculus (TRC) in DBMS

Tuple Relational Calculus is a non-procedural query language unlike relational algebra. Tuple Calculus provides only the description of the query but it does not provide the methods to solve it. Thus, it explains what to do but not how to do.
In Tuple Calculus, a query is expressed as
{t| P(t)}
where t = resulting tuples,
P(t) = known as Predicate and these are the conditions that are used to fetch t
Thus, it generates set of all tuples t, such that Predicate P(t) is true for t.
P(t) may have various conditions logically combined with OR (∨), AND (∧), NOT(¬).
It also uses quantifiers:
∃ t ∈ r (Q(t)) = ”there exists” a tuple in t in relation r such that predicate Q(t) is true.
∀ t ∈ r (Q(t)) = Q(t) is true “for all” tuples in relation r.

Example:
Table-1: Customer

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)Table-2: Branch

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

Table-3: Account

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)Table-4: Loan

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)Table-5: Borrower

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

Table-6: Depositor

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)


Queries-1: Find the loan number, branch, amount of loans of greater than or equal to 10000 amount.
{t| t ∈ loan  ∧ t[amount]>=10000}
Resulting relation:
Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)In the above query, t[amount] is known as tupple variable.

Queries-2: Find the loan number for each loan of an amount greater or equal to 10000.
{t| ∃ s ∈ loan(t[loan number] = s[loan number]  
                   ∧ s[amount]>=10000)}
Resulting relation:
Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)
Queries-3: Find the names of all customers who have a loan and an account at the bank.
{t | ∃ s ∈ borrower( t[customer-name] = s[customer-name])  
    ∧  ∃ u ∈ depositor( t[customer-name] = u[customer-name])}
Resulting relation:
Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)
Queries-4: Find the names of all customers having a loan at the “ABC” branch.
{t | ∃ s ∈ borrower(t[customer-name] = s[customer-name]  
    ∧ ∃ u ∈  loan(u[branch-name] = “ABC” ∧ u[loan-number] = s[loan-number]))}
Resulting relation:

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

Domain Relational Calculus in DBMS

Domain Relational Calculus is a non-procedural query language equivalent in power to Tuple Relational Calculus. Domain Relational Calculus provides only the description of the query but it does not provide the methods to solve it. In Domain Relational Calculus, a query is expressed 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.

Predicate Calculus Formula

  1. Set of all comparison operators
  2. Set of connectives like and, or, not
  3. Set of quantifiers

Example:
Table-1: Customer

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

Table-2: Loan

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

Table-3: Borrower

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

Query-1: Find the loan number, branch, amount of loans of greater than or equal to 100 amount.
{≺l, b, a≻ | ≺l, b, a≻ ∈ loan ∧ (a ≥ 100)}
Resulting relation:

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)


Query-2: Find the loan number for each loan of an amount greater or equal to 150.
{≺l≻ | ∃ b, a (≺l, b, a≻ ∈ loan ∧ (a ≥ 150)}
Resulting relation:

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)


Query-3: Find the names of all customers having a loan at the “Main” branch and find the loan amount.
{≺c, a≻ | ∃ l (≺c, l≻ ∈ borrower ∧ ∃ b (≺l, b, a≻ ∈ loan ∧ (b = “Main”)))}
Resulting relation:

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

Note: The domain variables those will be in resulting relation must appear before | within ≺ and ≻ and all the domain variables must appear in which order they are in original relation or table.

The document Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Database Management System (DBMS).
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
62 videos|66 docs|35 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Relational Calculus - Database Management System (DBMS) - Computer Science Engineering (CSE)

1. What is Tuple Relational Calculus (TRC) in DBMS?
Ans. Tuple Relational Calculus (TRC) is a non-procedural query language used in database management systems (DBMS). It is based on the mathematical concept of first-order logic and is used to retrieve data from relational databases by specifying a condition that the desired tuples must satisfy.
2. How does Tuple Relational Calculus differ from Domain Relational Calculus?
Ans. Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC) are both query languages used in DBMS, but they have some differences. TRC operates on entire tuples of relations, while DRC operates on individual attributes of relations. TRC uses existentially quantified variables, whereas DRC uses universally quantified variables. TRC is more expressive and flexible, but DRC is easier to use and understand.
3. What are the advantages of using Tuple Relational Calculus?
Ans. Tuple Relational Calculus (TRC) offers several advantages in database management systems. Firstly, it provides a declarative approach to querying databases, allowing users to focus on what data they want rather than how to retrieve it. TRC is also independent of the physical storage and organization of data, making it more portable across different DBMS implementations. Additionally, TRC allows for complex and expressive queries, enabling users to specify intricate conditions for retrieving data.
4. Can Tuple Relational Calculus be used for complex queries?
Ans. Yes, Tuple Relational Calculus (TRC) can be used for complex queries in database management systems. TRC allows for the use of conjunction, disjunction, and negation operators to combine multiple conditions. It also supports nested queries, where the condition of one query is based on the results of another query. With these capabilities, TRC can handle complex queries involving multiple tables, conditions, and logical operations.
5. Is Tuple Relational Calculus widely used in practice?
Ans. While Tuple Relational Calculus (TRC) is a powerful query language, it is not widely used in practice compared to other query languages like Structured Query Language (SQL). TRC has a more complex syntax and requires a deeper understanding of logic and set theory. SQL, on the other hand, is more user-friendly and widely supported by various DBMSs. However, TRC is still used in academic and research settings, where its expressive power and logical foundation are valued.
62 videos|66 docs|35 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

ppt

,

pdf

,

past year papers

,

shortcuts and tricks

,

Semester Notes

,

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Free

,

Summary

,

Sample Paper

,

video lectures

,

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

study material

,

Objective type Questions

,

mock tests for examination

,

practice quizzes

,

Previous Year Questions with Solutions

,

Relational Calculus | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Exam

,

MCQs

,

Extra Questions

,

Important questions

,

Viva Questions

;