10.RC_TRC_DRC
10.RC_TRC_DRC
On
DBMS-CS116
Comparison of Relational Algebra &
Relational Calculus
The solution to the database access problem The solution to the database access problem
using a relational algebra is obtained by stating using a relational calculus is obtained simply
what is required and what are the steps to by stating what is required and letting the
obtain that information. system find the answer.
It is used as a vehicle for implementation of Relational calculus queries are converted into
Relational Calculus. equivalent relational algebra format by using
Codd’s reduction algorithm and then it is
implemented with the help of relational algebra
operators.
Relational algebra operators are used as a A language is said to be complete if it is at least
yardstick for measuring the expressive power as powerful as the calculus.
of any given language.
• Variable predicate
What is Relational Calculus?
• Query: {T | P(T)}
• T is tuple variable
• P(T) is a formula that describes T
• Result, the set of all tuples t for which P(t) evaluates True.
• Find all sailors with a rating above 7.
• Atomic formula
• R.a op S.b , op is one of R.a op constant
Tuple Relational Calculus
• Query: {T|P(T)}
• T is tuple variable
• P(T) is a formula that describes T
Result: the set of all tuples t for which P(t) evaluates True.
Find all sailors with a rating above 7.
Operations In Tuple Relational Calculus
• ∧ - AND
• ∨ - OR
• ¬ - NOT
• ∃x – there exists x
• ∀x – for all x
Note: General power of 1st order predicate calculus – allow more flexible
expression formats
Tuple Relational Calculus
Tuple Relational Calculus
Examples
Relation 3:
Examples
x1, x2,...,xn
Answer includes all tuples that
make the formula p x1, x2,..., xn
be true.
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)}
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)}
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”)))}
Relational Calculus: Summary
OTHER REFRENCES
• https://cs.uwaterloo.ca/~tozsu/courses/CS348/notes/4b-calculus-handout-notes.pdf
• http://www.ccs.neu.edu/home/kathleen/classes/cs3200/4-RAAndRC.pdf
• https://www2.cs.sfu.ca/CourseCentral/354/louie/Chap3_practice.pdf
• http://www.nyu.edu/classes/jcf/CSCI-GA.2433-001_fa11/slides/session5/RelationalAlgebra-Re
lationalCalculus-SQL.pdf
• https://blog.inf.ed.ac.uk/da15/files/2015/01/inf1-da-15-t3.pdf
•Database System Concepts by Sudarshan, Korth(McGraw-HillEducation)
•http://ecomputernotes.com/database-system/rdbms
•https://www.tutorialspoint.com/sql/sql-rdbms-concepts.htm
•https://www.studytonight.com/dbms/rdbms-concept
SUGGESTED BOOK REFERENCES
• Ramez Elmasri and Shamkant B. Navathe,“Fundamentals of Database System”, The
Benjamin / Cummings Publishing Co.
• Korth and Silberschatz Abraham, “Database SystemConcepts”, McGraw Hall.
• Pratt,”DBMS”, Cengage Learning.