CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 1 What is a Query Language? Universality of Data Retrieval Languages, Aho and Ullman, POPL 1979 Raghu.

Slides:



Advertisements
Similar presentations
Properties of Regular Sets
Advertisements

Relational Calculus and Datalog
Chapter Three: Closure Properties for Regular Languages
Lecture 11: Datalog Tuesday, February 6, Outline Datalog syntax Examples Semantics: –Minimal model –Least fixpoint –They are equivalent Naive evaluation.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
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 Ch. 7.4 – 7.6 John Ortiz. Lecture 4Relational Algebra2 Relational Query Languages  Query languages: allow manipulation and retrieval.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A Modified by Donghui Zhang.
INFS614, Fall 08 1 Relational Algebra Lecture 4. INFS614, Fall 08 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
1 Module 9 Recursive and r.e. language classes –representing solvable and half-solvable problems Proofs of closure properties –for the set of recursive.
Lecture 8 Recursively enumerable (r.e.) languages
1 Module 21 Closure Properties for LFSA using NFA’s –From now on, when I say NFA, I mean any NFA including an NFA- unless I add a specific restriction.
Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#
FALL 2004CENG 351 File Structures and Data Managemnet1 Relational Algebra.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
1 Relational Algebra. 2 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
Relational Algebra Chapter 4 - part I. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
1 Lecture 19 Closure Properties for LFSA using NFA’s –union second proof –concatenation –Kleene closure.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Introduction to Database Systems 1 Relational Algebra Relational Model: Topic 3.
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.
Deductive Databases Chapter 25
CSCD343- Introduction to databases- A. Vaisman1 Relational Algebra.
Relational Algebra, R. Ramakrishnan and J. Gehrke (with additions by Ch. Eick) 1 Relational Algebra.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Section 4.3.
Lecture 05 Structured Query Language. 2 Father of Relational Model Edgar F. Codd ( ) PhD from U. of Michigan, Ann Arbor Received Turing Award.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
1 Relational Algebra. 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of data from a database. v Relational model supports.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
Number Theory Project The Interpretation of the definition Andre (JianYou) Wang Joint with JingYi Xue.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra.
CS 4432query processing1 CS4432: Database Systems II Lecture #11 Professor Elke A. Rundensteiner.
1 Relational Algebra and Calculas Chapter 4, Part A.
1.1 CAS CS 460/660 Introduction to Database Systems Relational Algebra.
Database Management Systems 1 Raghu Ramakrishnan Relational Algebra Chpt 4 Xin Zhang.
1 Relational Algebra Chapter 4, Sections 4.1 – 4.2.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 4 Relational Algebra.
Database Management Systems 1 Raghu Ramakrishnan Relational Algebra Chpt 4 Xin Zhang.
CSCD34-Data Management Systems - A. Vaisman1 Relational Algebra.
Database Management Systems, R. Ramakrishnan1 Relational Algebra Module 3, Lecture 1.
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2010 Most slides modified from Discrete Mathematical Structures: Theory and Applications by D.S. Malik.
1 CS 430 Database Theory Winter 2005 Lecture 5: Relational Algebra.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
CS 203: Introduction to Formal Languages and Automata
Database Management Systems 1 Raghu Ramakrishnan Relational Algebra Chpt 4 Jianping Fan.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
Lecture 9: Query Complexity Tuesday, January 30, 2001.
Goal for this lecture Demonstrate how we can prove that one query language is more expressive than (i.e., “contained in” as described in the book) another.
Formal Language & Automata Theory
Relational Algebra Chapter 4, Part A
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
Relational Algebra.
Relational Algebra Chapter 4 - part I.
Relational Algebra Chapter 4, Sections 4.1 – 4.2
Lecture 10: Query Complexity
CENG 351 File Structures and Data Managemnet
Relational Algebra Chapter 4 - part I.
Presentation transcript:

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 1 What is a Query Language? Universality of Data Retrieval Languages, Aho and Ullman, POPL 1979 Raghu Ramakrishnan

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 2 What is …?  What Is A Query Language? A language that allows retrieval and manipulation of data From a database.  What Is A Database? A large collection of DATA The data can be grouped into sets whose elements have similar structure.  What Kind of Structure Can the Data Have?  What Kind of Manipulation Should Be Allowed?

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 3 Some Ideas  Relations should be treated as sets of tuples.  The query language must have a simple, non- operational meaning that is independent of physical data representation.  There must be efficient ways to process queries over (large) sets of similarly structured facts. We will focus on the relational model

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 4 Principles for A Relational Query Language* 1) Relation = Set of Tuples. Ordering & other storage details should not be visible. 2) Data Values should not be ‘Interpreted’. Note: (2) Says that no special meaning should be attached to data values (as far as the query language is concerned); thus, Arithmetic is Disallowed! 5+6 = 11, 8<9, … * Proposed by Aho & Ullman

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 5 Principles – Refinement  Principle (2) is too restrictive.  Relax it slightly: Note: If we include +, ×, etc. to P, soon only the identity function will preserve P!

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 6 Allowable Fns – Transitive Closure  Aho & Ullman’s notation of allowable function is rather restrictive. However: 1.All Relational Algebra queries are allowable. 2.Transitive Closure is allowable.  And they prove that: There is no Relational Algebra query that computes the Transitive Closure of a Relation. Any R.A expression has a fixed size, say n. Choose Relation R: a 1 a 2 a k k > n The relational algebra expression cannot deal with (a 1, a k ).

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 7 Proposal  We should extent RA to support a least fixpoint operator. Leads to recursive queries Some systems (e.g., Oracle) support limited forms of recursion like transitive closure. Others (DB2) support linear recursion, following SQL:1999.

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 8 Least Fixpoints  The LFP operator is defined as follows:  Theorem (Tarski): There is a least fixpoint satisfying LFP(R=f(R)) if ‘ f ’ is monotone. Note: If ‘f’ is a relation algebra expression without ‘−’ (set diff.), then it is monotone.

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 9 Least Fixpoint – Cont.  Theorem (Kleene)  Example: Transitive Closure

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 10 LFP - Cont.  Claim: The LFP operator satisfies principles 1&2  Theorem (Aho-Ullman): There is no relational algebra expression E(R) that computes the transitive closure of an arbitrary input relation R.

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 11 Proof a1a1 a2a2 a3a3 alal

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 12 a1a1 a2a2 a m-c b j alal a m b j +c Note: Here (b j +c) ≡ a m s.t. b j =a m-c

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 13 aiai amam a m+d a m+c c

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 14 amb2amb2 a m+d b 1

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 15 Proof of lemma

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 16 Transitive closure - more a1a1 a2a2 a3a3 alal

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 17 Transitive closure - more a1a1 a2a2 a3a3 alal YES! But it is NOT a relation algebra expression! a1a1 a4a4 a2a2 a3a3 What does “a i <a j ” mean now?!

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 18 BP-Completeness  A query language is BP-complete if: All functions that can be expressed in the language are allowable. Let r 1 and r 2 be two relations (instances), such that for all renamings μ Then there is a function f in the language such that

CS 286, UC Berkeley, Spring 2007, R. Ramakrishnan 19 Example of BP-Complete A B C D E F If ‘A’ is used as ‘r 1 ’ in previous slide, which of the others qualifies as ‘r 2 ’? 2.For each such relation, find relational algebra function f.