Institut für Informationssysteme

Slides:



Advertisements
Similar presentations
1 Datalog: Logic Instead of Algebra. 2 Datalog: Logic instead of Algebra Each relational-algebra operator can be mimicked by one or several Database Logic.
Advertisements

Relational Calculus and Datalog
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 Calculus Chapter 4, Part B.
Databases and Information Systems 1 Prof. Dr. Stefan Böttcher Fakultät EIM, Institut für Informatik Universität Paderborn WS 2009 / 2010 Contents: selectivity.
1 541: Relational Calculus. 2 Relational Calculus  Comes in two flavours: Tuple relational calculus (TRC) and Domain relational calculus (DRC).  Calculus.
1 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke Deductive Databases Chapter 25.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
1 9. Evaluation of Queries Query evaluation – Quantifier Elimination and Satisfiability Example: Logical Level: r   y 1,…y n  r’ Constraint.
Winter 2002Arthur Keller – CS 18014–1 Schedule Today: Feb. 26 (T) u Datalog. u Read Sections Assignment 6 due. Feb. 28 (TH) u Datalog and SQL.
Conjunctive Queries, Datalog, and Recursion Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 23, 2003 Some slide.
CS240A: Databases and Knowledge Bases Fixpoint Semantics of Datalog Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
CSE 636 Data Integration Datalog Rules / Programs / Negation Slides by Jeffrey D. Ullman.
Relational Calculus. Another Theoretical QL-Relational Calculus n Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus.
2005conjunctive1 Query languages, equivalence & containment  conjunctive queries – CQ’s  More expressive languages.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Using Definite Knowledge Notes for Ch.3 of Poole et al. CSCE 580 Marco Valtorta.
Chapter 5 Other Relational Languages By Cui, Can B.
Embedded SQL Direct SQL is rarely used: usually, SQL is embedded in some application code. We need some method to reference SQL statements. But: there.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Cs5611 Recursive SQL, Deductive Databases, Query Evaluation Slides based on book chapter, By Ramankrishnan and Gehrke DBMS Systems, 3 rd ed.
Credit: Slides are an adaptation of slides from Jeffrey D. Ullman 1.
Deductive Databases Chapter 25
Rutgers University Relational Calculus 198:541 Rutgers University.
Cost-based Optimization of Graph Queries Silke Trißl Humboldt-Universität zu Berlin Knowledge Management in Bioinformatics IDAR 2007.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Calculus Chapter 4, Section 4.3.
Logical Query Languages Motivation: 1.Logical rules extend more naturally to recursive queries than does relational algebra. u Used in SQL recursion. 2.Logical.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4.
Datalog Inspired by the impedance mismatch in relational databases. Main expressive advantage: recursive queries. More convenient for analysis: papers.
1 Querying Infinite Databases Safety of Datalog Queries over infinite Databases (Sagiv and Vardi ’90) Queries and Computation on the Web (Abiteboul and.
Relational Calculus R&G, Chapter 4. Relational Calculus Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus (DRC). Calculus.
1 Relational Algebra and Calculas Chapter 4, Part A.
Datalog –Another query language –cleaner – closer to a “logic” notation, prolog – more convenient for analysis – can express queries that are not expressible.
+ Represent Relations and Functions. + Relation A relation is a mapping, or pairing, of input values with output values. The set of input values in the.
1 Data Models and Query Languages CSE 590DB, Winter 1999 Theory of Databases Zack Ives January 10, 1999.
Deriving Ramsey Numbers Interim Project Evaluations Team 7 Albuquerque Academy.
FUNCTIONS Relation – a set of ( x, y ) points Function – a set of ( x, y ) points where there is only one output for each specific input – x can not be.
Computing & Information Sciences Kansas State University Wednesday, 17 Sep 2008CIS 560: Database System Concepts Lecture 9 of 42 Wednesday, 18 September.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L5_Relational Calculus 1 Relational Calculus Chapter 4 – Part B.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4, Part B.
Web-Mining Agents Prof. Dr. Ralf Möller Universität zu Lübeck Institut für Informationssysteme Tanya Braun (Übungen)
1 Datalog with negation Adapted from slides by Jeff Ullman.
1 Finite Model Theory Lecture 9 Logics and Complexity Classes (cont’d)
CS589 Principles of DB Systems Fall 2008 Lecture 4c: Query Language Equivalence Lois Delcambre
Datenbanken Prof. Dr. Ralf Möller Universität zu Lübeck Institut für Informationssysteme Karsten Martiny (Übungen) und studentische Tutoren.
1 11. Certification Certification – algorithms/methods to verify that a program is safe. Used when restriction does not work because we use a combination.
Relational Calculus Chapter 4, Section 4.3.
2.1/2.2 Solving Inequalities
CSE202 Database Management Systems
CS589 Principles of DB Systems Spring 2014 Unit 2: Recursive Query Processing Lecture 2-1 – Naïve algorithm for recursive queries Lois Delcambre (slides.
Datalog Rules / Programs / Negation Slides by Jeffrey D. Ullman
Lois Delcambre (slides from Dave Maier)
Relational Calculus Chapter 4, Part B
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.
Semantics of Datalog With Negation
Web-Mining Agents Cooperating Agents for Information Retrieval
Jess Architecture Diagram WORKING MEMORY INFERENCE ENGINE EXECUTION ENGINE PATTERN MATCHER RULE BASE Here you can see how all the parts fit.
CSE 344: Section 5 Datalog February 1st, 2018.
Lecture 10: Relational Algebra (continued), Datalog
Cse 344 January 29th – Datalog.
Motivation for Datalog
Lecture 9: Relational Algebra (continued), Datalog
1.1- Relations and Functions
CS 186, Fall 2002, Lecture 8 R&G, Chapter 4
Logic Based Query Languages
Brief Introduction to Computational Logic
Datalog Inspired by the impedance mismatch in relational databases.
Non-Standard-Datenbanken
Relational Calculus Chapter 4, Part B 7/1/2019.
CS589 Principles of DB Systems Fall 2008 Lecture 4e: Logic (Model-theoretic view of a DB) Lois Delcambre
CS589 Principles of DB Systems Fall 2008 Lecture 4b: Domain Independence and Safety Lois Delcambre
Presentation transcript:

Institut für Informationssysteme Datenbanken Prof. Dr. Ralf Möller Universität zu Lübeck Institut für Informationssysteme Karsten Martiny (Übungen) und studentische Tutoren

Danksagung Einige Präsentationen zu wurden mit Änderungen übernommen aus einer Präsentation von Stephanie Scherzinger

Datalog: Recursive Queries  x,y ( T(x,y)  G(x,y) ) x,y,z ( T(x,y)  ( G(x,z)  T(z,y) ) ) G( 1, 2 ), G( 2, 3 ), G( 3, 2 ) G: 1 2 3 Possible solutions: 1 1 2 2 1 2 3 3 3 Herve Gallaire und Jack Minker Logic and Data Bases. Symposium on Logic and Data Bases, Centre d’études et de recherches de Toulouse in „Advances in Data Base Theory“. Plenum Press, New York 1978

Model Theoretic Approach  x,y ( T(x,y)  G(x,y) ) x,y,z ( T(x,y)  ( G(x,z)  T(z,y) ) ) G( 1, 2 ), G( 2, 3 ), G( 3, 2 ) G: 1 2 3 Possible solutions: 1 1 2 2 1 2 3 3 3 Chose the minimum model  T consists of the smallest set of facts that make the sentences true.

Recursive query in Datalog(rec, no-neg) notation Reachability or Transitive closure of a graph: T(x,y) :- G(x,y) T(x,y) :- G(x,z), T(z,y)

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(x,y) T(x,y) :- G(x,z), T(z,y) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ |

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(1,2) T(x,y) :- G(x,z), T(z,y) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ | (1) Map from instances over the relations in the rule body

Transitive closure of a graph: Intuition Transitive closure of a graph: T(1,2) :- G(1,2) T(x,y) :- G(x,z), T(z,y) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ | (2) ... map to instances over the relations in the rule head

Transitive closure of a graph: Intuition Transitive closure of a graph: T(1,2) :- G(1,2) T(x,y) :- G(x,z), T(z,y) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ 1 | 2 | (2) ... map to instances over the relations in the rule head

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(x,y) T(x,y) :- G(x,z), T(z,y) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ 1 | 2 2 | 3 |

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(x,y) T(x,y) :- G(x,z), T(z,y) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ 1 | 2 2 | 3 3 | 2

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(x,y) T(x,y) :- G(1,2), T(2,3) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ 1 | 2 2 | 3 3 | 2 (1) Map from instances over the relations in the rule body

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(x,y) T(1,3) :- G(1,2), T(2,3) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ 1 | 2 2 | 3 3 | 2 (2) ... map to instances over the relations in the rule head

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(x,y) T(1,3) :- G(1,2), T(2,3) 1 2 3 G____ 1 | 2 2 | 3 3 | 2 T____ 1 | 2 2 | 3 3 | 2 1 | 3 (2) ... map to instances over the relations in the rule head

Transitive closure of a graph: Intuition Transitive closure of a graph: T(x,y) :- G(x,y) T(x,y) :- G(x,z), T(z,y) 1 2 3 T____ 1 | 2 2 | 3 3 | 2 1 | 3 2 | 2 3 | 3 G____ 1 | 2 2 | 3 3 | 2 ... repeat until fixpoint is reached (datalog without negation is monotone)

Correctness  x,y ( T(x,y)  G(x,y) )  x,y,z ( T(x,y)  ( G(x,z)  T(z,y) ) ) G( 1,2 ), G( 2,3 ), G( 3, 2 ) G: 1 2 3 Possible solutions: 1 1 2 2 1 2 3 3 3 Chose the minimum model  T consists of the smallest set of facts that make the sentences true.

Works only for Safe Datalog Here: Datalog without negation. Notion of range-restricted queries. This query is not safe: Colored_edges(x,y,col) :- G(x,y) Every variable in the head of a rule must also appear in the body (or must be range-restricted in case of built-in ops)

Evaluation in SQL with Joins  x,y ( T(x,y)  G(x,y) )  x,y,z ( T(x,y)  ( G(x,z)  T(z,y) ) ) G( 1,2 ), G( 2,3 ), G( 3, 2 ) G(x,z)  T(z,y) is a join Need joins until fixpoint over all data (naive evaluation) Need to consider only newly derived data (semi-naive)

Zusammenfassung, Kernpunkte Keine Angst vor rekursiven Anfragen: Effiziente Auswertung möglich Keine Endlosschleifen zu befürchten Aber: Sicherheitsbedingungen (gilt auch für rekursive Anfragen in SQL)