Notes Chapter 1.3 Lecture 1.3.3 (Tuple Relational Calculus)
Notes Chapter 1.3 Lecture 1.3.3 (Tuple Relational Calculus)
CHAPTER 1.2
(Tuple Relational Calculus)
Relational Calculus
For example, steps involved in listing all the students who attend ‘Database’ Course in
relational algebra would be
1.The tuple relational calculus is a nonprocedural language. (The relational algebra was
procedural.)
{t| P(t)}
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(¬).
∃ t ∈ r (Q(t)) = ”there exists” a tuple in t in relation r such that predicate Q(t) is true.
Example:
Table-1: Customer
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
Table-4: Loan
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.
Resulting relation:
Queries-2: Find the loan number for each loan of an amount greater or equal to 10000.
∧ 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.
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]
Resulting relation:
Customer name
Saurabh
OTHER REFRENCES