1 CS 430 Database Theory Winter 2005 Lecture 6: Relational Calculus.

Slides:



Advertisements
Similar presentations
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 5: Other Relational.
Advertisements

Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Part B.
The Relational Calculus
Chapter 3 Tuple and Domain Relational Calculus. Tuple Relational Calculus.
1 541: Relational Calculus. 2 Relational Calculus  Comes in two flavours: Tuple relational calculus (TRC) and Domain relational calculus (DRC).  Calculus.
Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra.
Domain Relational Calculus and Query-by-Example CS157a John Eagle.
Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using.
Relational Calculus. Another Theoretical QL-Relational Calculus n Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus.
Chapter Predicate Calculus Formal language –True/False statements –Supports reasoning Usage –Integrity constraints –Non-procedural query languages.
1 Lecture 5: Relational calculus
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
SPRING 2004CENG 3521 E-R Diagram for the Banking Enterprise.
Introduction to Database Systems 1 Relational Calculus Relational Model : Topic 2.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Dr. Alexandra I. Cristea CS 319: Theory of Databases: C6.
Revision of Midterm 2 Prof. Sin-Min Lee Department of Computer Science.
Relational Algebra Wrap-up and Relational Calculus Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems September 11, 2003.
Rutgers University Relational Calculus 198:541 Rutgers University.
Chapter 4 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Relational Algebra.  Introduction  Relational Algebra Operations  Projection and Selection  Set Operations  Joins  Division  Tuple Relational Calculus.
DEDUCTIVE DATABASE.
Relational Algebra Example Database Application (COMPANY) Relational Algebra –Unary Relational Operations –Relational Algebra Operations From Set Theory.
Lecture 3 [Self Study] Relational Calculus
The Relational Model: Relational Calculus
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Section 4.3.
CS 380 Introduction to Database Systems Chapter 7: The Relational Algebra and Relational Calculus.
Chapter 8 Relational Calculus. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.8-2 Topics in this Chapter Tuple Calculus Calculus vs. Algebra.
CSE314 Database Systems The Relational Algebra and Relational Calculus Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 14 A First Course in Database Systems.
Relational Calculus Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems September 17, 2007 Some slide content courtesy.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 17 A First Course in Database Systems.
Relational Algebra. 2 Outline  Relational Algebra Unary Relational Operations Relational Algebra Operations from Set Theory Binary Relational Operations.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
The Relational Calculus (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Copyright © 2004 Ramez Elmasri and Shamkant Navathe The Relational Calculus The main reference of this presentation is the textbook and PPT from : Elmasri.
Database System Concepts, 5th Ed. Bin Mu at Tongji University Chapter 5: Other Relational Languages.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Module A: Formal Relational.
1 Copyright © Kyu-Young Whang Relational Calculus Chapter 4, Part B.
Slide 6- 1 Additional Relational Operations Aggregate Functions and Grouping A type of request that cannot be expressed in the basic relational algebra.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
Copyright © Curt Hill The Relational Calculus Another way to do queries.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L5_Relational Calculus 1 Relational Calculus Chapter 4 – Part B.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 11 A First Course in Database Systems.
Copyright © 2004 Pearson Education, Inc.. Chapter 6 The Relational Algebra and Relational Calculus.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4, Part B.
Chapter 6 The Relational Algebra and Calculus Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Relational Calculus. Relational calculus query specifies what is to be retrieved rather than how to retrieve it. – No description of how to evaluate a.
Jun-Ki Min.  Based on predicate calculus ◦ Predicate  a function whose value is true or false  non-procedural ◦ A relational calculus expression creates.
CS589 Principles of DB Systems Fall 2008 Lecture 4b: Domain Independence and Safety Lois Delcambre
Relational Algebra. CENG 3512 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports.
Relational Calculus Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Relational Calculus Chapter 4, Section 4.3.
Introduction to Relational Calculus Tuple Relational Calculus
CSE202 Database Management Systems
A First Course in Database Systems
CS 480: Database Systems Lecture 15 February 18, 2013.
Relational Calculus Chapter 4, Part B
The Relational Algebra and Relational Calculus
Elmasri/Navathe, Fundamentals of Database Systems, 4th Edition
Chapter 6: Formal Relational Query Languages
Relational Calculus Chapter 4, Part B 7/1/2019.
CS589 Principles of DB Systems Fall 2008 Lecture 4b: Domain Independence and Safety Lois Delcambre
Relational Calculus Chapter 4, Part B
Presentation transcript:

1 CS 430 Database Theory Winter 2005 Lecture 6: Relational Calculus

2 What is the Relational Calculus? Answer: A non-procedural way to specify relational queries  Relational algebra provides a procedural way to specify queries Why both?  History  SQL resembles Relational Calculus Relational Calculus came first  Way to compare the power of various query languages

3 Tuple and Domain Relational Calculus Two forms of Relational Calculus:  Tuple: Predicates on tuples  Domain: Predicates on attributes Relational Calculus (without qualification) refers to the Tuple Relational Calculus

4 Tuple Relational Calculus Example:  { t.FNAME, t.LNAME | EMPLOYEE(t) AND t.SALARY > } General:  { t 1.A 1, …, t n.A n | COND(t 1, …, t n+k ) }  t i are tuple variables  A i are attributes  COND is a condition or formula

5 Formulas Atoms  R(t) where R is a relation and t is a tuple variable True if the tuple t is a tuple of the relation R  x  y, where x and y are either t.A i, an attribute, or c, a constant, and  is a comparison operator Conditions (aka Formulas)  Atoms  Boolean combinations (AND, OR, NOT) of formulas  Existential and Universal Quantifiers

6 Existential and Universal Quantifiers (  t) (F)  “For all t, F is True”  True if F is True for any possible tuple assigned to a free occurrence of t in F (  t) (F)  “There exists t such that F is True”  True if F is True for some tuple assigned to a free occurrence of t in F t is a tuple variable F is a formula

7 Safe Expressions A safe expression is one guaranteed to yield a finite number of tuples Non-safe expression:  { t | NOT( EMPLOYEE(t)) } Domain of an expression: All values that exist in any tuple in the relations referenced in the expression and all constants used in the expression An expression is safe if all resulting values are from the domain of the expression  Note that by definition this is a finite collection Usual use: All tuples t are qualified by an atom of the form R(t)

8 Domain Relational Calculus { x 1, …, x n | COND(x 1, …, x n+k ) } x i are value variables COND is a condition or formula  Same structure as formula for Tuple Relational Calculus, except: R(x 1, …, x n ), where R is a relation, is True if is a tuple of R Example:  { q, s | (  r) (  t) (  u) (  v) (  w) (  x) (  y) (  z) EMPLOYEE(qrstuvwxyz) AND x > } Shorthand  { qs | EMPLOYEE(qrstuvwxyz) AND x > }

9 Relationally Complete A query language is “Relationally Complete” if it has the power of the Relational Calculus The Basic Relational Algebra (one with the original operations) is equivalent in power to the Relational Calculus  Any expression in the Basic Relational Algebra has a corresponding expression in either Relational Calculus  Any Safe expression in Relational Calculus has a corresponding expression in the Relational Algebra  Note that the Relational Calculus (as given here) doesn’t include equivalents to EXTEND and AGGREGATION

10 Examples