Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications C. Faloutsos Relational tuple calculus.

Slides:



Advertisements
Similar presentations
CMU SCS Carnegie Mellon Univ. School of Computer Science /615 - DB Applications C. Faloutsos & A. Pavlo Lecture #4: Relational Algebra.
Advertisements

Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Part B.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos & A. Pavlo Lecture#6: Rel. model - SQL part1 (R&G, chapter.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
D ATABASE S YSTEMS I R ELATIONAL A LGEBRA. 22 R ELATIONAL Q UERY L ANGUAGES Query languages (QL): Allow manipulation and retrieval of data from a database.
Relational Algebra Dashiell Fryer. What is Relational Algebra? Relational algebra is a procedural query language. Relational algebra is a procedural query.
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.
1 Relational Algebra & Calculus. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
Domain Relational Calculus and Query-by-Example CS157a John Eagle.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Lecture#7 (cont’d): Rel. model - SQL part3.
Relational Calculus. Another Theoretical QL-Relational Calculus n Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus.
Relational Calculus CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 Mary Roth   We will occasionally use this arrow notation unless there is danger of.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Rutgers University Relational Algebra 198:541 Rutgers University.
Relational Algebra Chapter 4 - part I. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
Relational Calculus CS 186, Fall 2003, Lecture 6 R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion.
Rutgers University Relational Calculus 198:541 Rutgers University.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos & A. Pavlo Lecture#7 : Rel. model - SQL part2 (R&G, chapters.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Rel. model - SQL part1.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Relational Model – SQL Part I (based on notes by Silberchatz,Korth,
Relational Algebra.  Introduction  Relational Algebra Operations  Projection and Selection  Set Operations  Joins  Division  Tuple Relational Calculus.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
Relational Algebra Instructor: Mohamed Eltabakh 1.
Lecture 3 [Self Study] Relational Calculus
Logic Specification and Z Schema 3K04 McMaster. Basic Logic Operators Logical negation ( ¬ ) Logical conjunction ( Λ or & ) Logical disjunction ( V or.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Relational Model III (based on notes by Silberchatz,Korth, and.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Section 4.3.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Relational Model – SQL Part II (based on notes by Silberchatz,Korth,
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.
1 Relational Algebra. 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of data from a database. v Relational model supports.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science Database Applications Lecture#6: Relational calculus.
Relational Calculus R&G, Chapter 4. Relational Calculus Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus (DRC). Calculus.
Relational Calculus CS 186, Spring 2005, Lecture 9 R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion.
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra)
1 Relational Algebra and Calculas Chapter 4, Part A.
Relational Algebra.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Distributed DB.
1 Relational Algebra Chapter 4, Sections 4.1 – 4.2.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Rel. model - SQL part3.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Relational model.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Relational Model I (based on notes by Silberchatz,Korth, and Sudarshan.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Relational domain calculus.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 – DB Applications C. Faloutsos & A. Pavlo Lecture#5: Relational calculus.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Module A: Formal Relational.
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Rel. model - SQL part2.
CSC271 Database Systems Lecture # 7. Summary: Previous Lecture  Relational keys  Integrity constraints  Views.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L5_Relational Calculus 1 Relational Calculus Chapter 4 – Part B.
1 Dept. of CIS, Temple Univ. CIS616/661 – Principles of Data Management V. Megalooikonomou SQL (part 2) (based on slides by C. Faloutsos at CMU)
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4, Part B.
Temple University – CIS Dept. CIS616– Principles of Database Systems V. Megalooikonomou Relational Model (based on notes by Silberchatz,Korth, and Sudarshan.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
LECTURE THREE RELATIONAL ALGEBRA 11. Objectives  Meaning of the term relational completeness.  How to form queries in relational algebra. 22Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 6 th Edition Chapter 8: Relational Algebra.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Relational Calculus Chapter 4, Section 4.3.
Temple University – CIS Dept. CIS661– Principles of Database Systems
Lecture #4: Relational Algebra
Data Base System Lecture 9: Rational Algebra and Relational Calculus
Database Applications (15-415) Relational Calculus Lecture 6, September 6, 2016 Mohammad Hammoud.
Lecture#5: Relational calculus
C. Faloutsos Query Optimization – part 2
Relational Algebra & Calculus
Relational Calculus Chapter 4, Part B 7/1/2019.
Presentation transcript:

Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Relational tuple calculus

Carnegie Mellon C. Faloutsos2 General Overview - rel. model history concepts Formal query languages –relational algebra –rel. tuple calculus –rel. domain calculus

Carnegie Mellon C. Faloutsos3 Overview - detailed rel. tuple calculus –why? –details –examples –equivalence with rel. algebra –more examples; ‘safety’ of expressions re. domain calculus + QBE

Carnegie Mellon C. Faloutsos4 Motivation Q: weakness of rel. algebra? A: procedural –describes the steps (ie., ‘how’) –(still useful, for query optimization)

Carnegie Mellon C. Faloutsos5 Solution: rel. calculus –describes what we want –two equivalent flavors: ‘tuple’ and ‘domain’ calculus –basis for SQL and QBE, resp.

Carnegie Mellon C. Faloutsos6 Rel. tuple calculus (RTC) first order logic ‘Give me tuples ‘t’, satisfying predicate P - eg:

Carnegie Mellon C. Faloutsos7 Details symbols allowed: quantifiers

Carnegie Mellon C. Faloutsos8 Specifically Atom

Carnegie Mellon C. Faloutsos9 Specifically Formula: –atom –if P1, P2 are formulas, so are –if P(s) is a formula, so are

Carnegie Mellon C. Faloutsos10 Specifically Reminders: –DeMorgan –implication: –double negation: ‘every human is mortal : no human is immortal’

Carnegie Mellon C. Faloutsos11 Reminder: our Mini-U db

Carnegie Mellon C. Faloutsos12 Examples find all student records output tuple of type ‘STUDENT’

Carnegie Mellon C. Faloutsos13 Examples (selection) find student record with ssn=123

Carnegie Mellon C. Faloutsos14 Examples (selection) find student record with ssn=123

Carnegie Mellon C. Faloutsos15 Examples (projection) find name of student with ssn=123

Carnegie Mellon C. Faloutsos16 Examples (projection) find name of student with ssn=123 ‘t’ has only one column

Carnegie Mellon C. Faloutsos17 ‘Tracing’ s t

Carnegie Mellon C. Faloutsos18 Examples cont’d (union) get records of both PT and FT students

Carnegie Mellon C. Faloutsos19 Examples cont’d (union) get records of both PT and FT students

Carnegie Mellon C. Faloutsos20 Examples difference: find students that are not staff (assuming that STUDENT and STAFF are union-compatible)

Carnegie Mellon C. Faloutsos21 Examples difference: find students that are not staff

Carnegie Mellon C. Faloutsos22 Cartesian product eg., dog-breeding: MALE x FEMALE gives all possible couples x =

Carnegie Mellon C. Faloutsos23 Cartesian product find all the pairs of (male, female)

Carnegie Mellon C. Faloutsos24 ‘Proof’ of equivalence rel. algebra rel. tuple calculus

Carnegie Mellon C. Faloutsos25 Overview - detailed rel. tuple calculus –why? –details –examples –equivalence with rel. algebra –more examples; ‘safety’ of expressions re. domain calculus + QBE

Carnegie Mellon C. Faloutsos26 More examples join: find names of students taking

Carnegie Mellon C. Faloutsos27 Reminder: our Mini-U db

Carnegie Mellon C. Faloutsos28 More examples join: find names of students taking

Carnegie Mellon C. Faloutsos29 More examples join: find names of students taking projection selection join

Carnegie Mellon C. Faloutsos30 More examples 3-way join: find names of students taking a 2-unit course

Carnegie Mellon C. Faloutsos31 Reminder: our Mini-U db

Carnegie Mellon C. Faloutsos32 More examples 3-way join: find names of students taking a 2-unit course selection projection join

Carnegie Mellon C. Faloutsos33 More examples 3-way join: find names of students taking a 2-unit course - in rel. algebra??

Carnegie Mellon C. Faloutsos34 Even more examples: self -joins: find Tom’s grandparent(s)

Carnegie Mellon C. Faloutsos35 Even more examples: self -joins: find Tom’s grandparent(s)

Carnegie Mellon C. Faloutsos36 Hard examples: DIVISION find suppliers that shipped all the ABOMB parts

Carnegie Mellon C. Faloutsos37 Hard examples: DIVISION find suppliers that shipped all the ABOMB parts

Carnegie Mellon C. Faloutsos38 General pattern three equivalent versions: –1) if it’s bad, he shipped it –2)either it was good, or he shipped it –3) there is no bad shipment that he missed

Carnegie Mellon C. Faloutsos39 More on division find (SSNs of) students that take all the courses that ssn=123 does (and maybe even more) find students ‘s’ so that if 123 takes a course => so does ‘s’

Carnegie Mellon C. Faloutsos40 More on division find students that take all the courses that ssn=123 does (and maybe even more)

Carnegie Mellon C. Faloutsos41 Safety of expressions FORBIDDEN: It has infinite output!! Instead, always use

Carnegie Mellon C. Faloutsos42 Overview - conclusions rel. tuple calculus: DECLARATIVE –dfn –details –equivalence to rel. algebra rel. domain calculus + QBE