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

Notes Chapter 1.3 Lecture 1.3.3 (Tuple Relational Calculus)

Tuple Relational Calculus is a non-procedural query language unlike relational algebra. It provides a description of the query by specifying a predicate condition without describing how to execute it. A query in Tuple Relational Calculus is expressed as {t|P(t)} where t are the resulting tuples and P(t) is the predicate that must be true for t. P(t) can include logical and quantifier conditions. Several example queries are provided to illustrate Tuple Relational Calculus.
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)
62 views5 pages

Notes Chapter 1.3 Lecture 1.3.3 (Tuple Relational Calculus)

Tuple Relational Calculus is a non-procedural query language unlike relational algebra. It provides a description of the query by specifying a predicate condition without describing how to execute it. A query in Tuple Relational Calculus is expressed as {t|P(t)} where t are the resulting tuples and P(t) is the predicate that must be true for t. P(t) can include logical and quantifier conditions. Several example queries are provided to illustrate Tuple Relational Calculus.
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

UNIT-1

CHAPTER 1.2
(Tuple Relational Calculus)

Relational Calculus

Relational calculus is a non procedural query language. It uses mathematical predicate


calculus instead of algebra. It provides the description about the query to get the result
where as relational algebra gives the method to get the result. It informs the system what to
do with the relation, but does not inform how to perform it.

For example, steps involved in listing all the students who attend ‘Database’ Course in
relational algebra would be

● SELECT the tuples from COURSE relation with COURSE_NAME = ‘DATABASE’


● PROJECT the COURSE_ID from above result
● SELECT the tuples from STUDENT relation with COUSE_ID resulted above.

There are two types of relational calculus

– Tuple Relational Calculus (TRC) and Domain Relational Calculus (DRC).

The Tuple Relational Calculus

1.The tuple relational calculus is a nonprocedural language. (The relational algebra was
procedural.)

2.We must provide a formal description of the information desired.

3.A query in the tuple relational calculus is expressed as

i.e. the set of tuples   for which predicate   is true.

4.We also use the notation

●  to indicate the value of tuple   on attribute  .


●  to show that tuple   is in relation  .

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

Customername Street City

Saurabh A7 Patiala

Mehak B6 Jalandhar

Sumiti D9 Ludhiana

Ria A5 Patiala

Table-2: Branch

Branchname Branchcity

ABC Patiala

DEF Ludhiana

GHI Jalandhar

Table-3: Account

Accountnumber Branchname Balance


1111 ABC 50000

1112 DEF 10000

1113 GHI 9000

1114 ABC 7000

Table-4: Loan

Loannumber Branchname Amount

L33 ABC 10000

L35 DEF 15000

L49 GHI 9000

L98 DEF 65000

Table-5: Borrower

Customername Loannumber

Saurabh L33

Mehak L49

Ria L98

Table-6: Depositor

Customername Accountnumber

Saurabh 1111

Mehak 1113

Sumiti 1114

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:

Loannumber Branchname Amount


L33 ABC 10000

L35 DEF 15000

L98 DEF 65000

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[loannumber] = s[loannumber]

∧ s[amount]>=10000)}

Resulting relation:

Loannumber

L33

L35

L98

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:

Customername

Saurabh

Mehak

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:

Customer name

Saurabh
OTHER REFRENCES

•      Relational Calculus - Tuple Relational Calculus - Domain Relational Calculus


(tutorialcup.com)

•      Tuple Relational Calculus (TRC) in DBMS - GeeksforGeeks

•     Tuple relational calculus - Wikipedia

SUGGESTED BOOK REFERENCES

1. C.J.Date, “An Introduction to DatabaseSystems”, Addison Wesley.


2. Thomas M. Connolly, Carolyn & E.Begg,“Database Systems: A Practical Approach to
Design, Implementationand Management”, 5/E, University of Paisley, Addison-
Wesley.
3. Rob,”Database Principal Fundamental Design, Cengage Learning.

You might also like