CSE 344: Section 5 Datalog February 1st, 2018.

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

1 Decidable Containment of Recursive Queries Diego Calvanese, Giuseppe De Giacomo, Moshe Y. Vardi presented by Axel Polleres
Relational Calculus and Datalog
CSE 636 Data Integration Conjunctive Queries Containment Mappings / Canonical Databases Slides by Jeffrey D. Ullman.
Lecture 11: Datalog Tuesday, February 6, Outline Datalog syntax Examples Semantics: –Minimal model –Least fixpoint –They are equivalent Naive evaluation.
Chapter 3 Tuple and Domain Relational Calculus. Tuple Relational Calculus.
1 Recursive SQL, Deductive Databases, Query Evaluation Book Chapter of Ramankrishnan and Gehrke DBMS Systems, 3 rd ed.
1 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke Deductive Databases Chapter 25.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
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.
CSE 636 Data Integration Datalog Rules / Programs / Negation Slides by Jeffrey D. Ullman.
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.
Mid-term Class Review.
Cs5611 Recursive SQL, Deductive Databases, Query Evaluation Slides based on book chapter, By Ramankrishnan and Gehrke DBMS Systems, 3 rd ed.
1 Datalog Logical Rules Recursion. 2 Logic As a Query Language uIf-then logical rules have been used in many systems. wMost important today: EII (Enterprise.
Deductive Databases Chapter 25
Logical Query Languages Motivation: 1.Logical rules extend more naturally to recursive queries than does relational algebra. u Used in SQL recursion. 2.Logical.
5.5 Solving Quadratic Equations by Factoring
Databases 1 8th lecture. Topics of the lecture Multivalued Dependencies Fourth Normal Form Datalog 2.
Do Now 10/26/10 In your notebook, explain how you know a function is a function. Then answer if the following three tables are functions or not. x
Recursive query plans for Data Integration Oliver Michael By Rajesh Kanisetti.
CSE314 Database Systems The Relational Algebra and Relational Calculus Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Logical Query Languages Motivation: 1.Logical rules extend more naturally to recursive queries than does relational algebra. u Used in SQL recursion. 2.Logical.
Datalog Inspired by the impedance mismatch in relational databases. Main expressive advantage: recursive queries. More convenient for analysis: papers.
Datalog –Another query language –cleaner – closer to a “logic” notation, prolog – more convenient for analysis – can express queries that are not expressible.
Chapter 5 Notes. P. 189: Sets, Bags, and Lists To understand the distinction between sets, bags, and lists, remember that a set has unordered elements,
Chapter 6 Section 5. Objectives 1 Copyright © 2012, 2008, 2004 Pearson Education, Inc. Solving Quadratic Equations by Factoring Solve quadratic equations.
Lu Chaojun, SJTU 1 Extended Relational Algebra. Bag Semantics A relation (in SQL, at least) is really a bag (or multiset). –It may contain the same tuple.
Database Management Systems Course Faculty of Computer Science Technion – Israel Institute of Technology Lecture 5: Queries in Logic.
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
Bell Ringer: Simplify each expression
CSE 311 Foundations of Computing I Lecture 20 Context-Free Grammars and Languages Autumn 2012 CSE
Database Management Systems Course Faculty of Computer Science Technion – Israel Institute of Technology Lecture 5: Queries in Logic.
Extensions of Datalog Wednesday, February 13, 2001.
1 Datalog with negation Adapted from slides by Jeff Ullman.
3.4 Chapter 3 Quadratic Equations. x 2 = 49 Solve the following Quadratic equations: 2x 2 – 8 = 40.
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
CS589 Principles of DB Systems Fall 2008 Lecture 4b: Domain Independence and Safety Lois Delcambre
Relational Calculus Chapter 4, Section 4.3.
Quadratic Functions.
Functions Section 5.1.
Datalog Rules / Programs / Negation Slides by Jeffrey D. Ullman
Quadratic Inequalities
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.
Database Management Systems
Semantics of Datalog With Negation
Cse 344 April 11th – Datalog.
February 7th – Exam Review
Cse 344 January 29th – Datalog.
Intro to Data Structures
Logic: Top-down proof procedure and Datalog
Motivation for Datalog
(Free to use. May not be sold)
Lecture 9: Relational Algebra (continued), Datalog
Final Review Datalog (Ch 10) Rules and queries
Local-as-View Mediators
Logic Based Query Languages
Brief Introduction to Computational Logic
Chapter 6 Section 5.
Datalog Inspired by the impedance mismatch in relational databases.
(Free to use. May not be sold)
Exponential Functions
Chapter 27: Formal-Relational Query Languages
Relational Calculus Chapter 4, Part B 7/1/2019.
CSE544 Wednesday, March 29, 2006.
CS589 Principles of DB Systems Fall 2008 Lecture 4b: Domain Independence and Safety Lois Delcambre
Graphing Data Section 1-3.
Rules Programs Negation
Presentation transcript:

CSE 344: Section 5 Datalog February 1st, 2018

Datalog Terminology Head - Body - Atom/Subgoal/Relational predicate Base Relations (EDB) vs Derived Relations (IDB) Negation + Aggregate Wildcard Helper(a,b):-Base1(a,b,_) NonAns(j):-Base2(j,k),!Base3(k) Ans(x):-Helper(x,y),!NonAns(y)

Query Safety Need a positive relational atom of every variable What’s wrong with this query? Find all of Alice’s children without children: U(x) :- ParentChild(“Alice”,x), !ParentChild(x,y) Want Alice’s childless children, but we get all children x (because there exists some y that x is not parent of y)

Query Safety U(x) :- ParentChild(“Alice”,x), !ParentChild(x,y) It is domain dependent! Unsafe! Double negation to the rescue. Why does this work? NonAns(x) :- ParentChild(“Alice”,x), ParentChild(x,y) # All of Alice’s children with children U(x) :- ParentChild(“Alice”,x), !NonAns(x) # All of Alice’s children without children (safe!) But we can do better...

Query Safety But we can do better... hasChild(x) :- ParentChild(x,_) # People with children U(x) :- ParentChild(“Alice”,x), !hasChild(x) # All of Alice’s children without children (safe!)

Datalog with Recursion Able to write complicated queries in a few lines Graph analysis Done with query once output does not change. VERY similar idea to context-free grammars (CSE 311)

Stratified Datalog Recursion might not work well with negation E.g. A(x):- Table(x), !B(x) B(x):- Table(x), !A(x) Solution: Don’t negate or aggregate on an IDB predicate until it is defined Stratified Datalog Query

Stratified Datalog Only IDB predicates defined in strata 1, 2, ..., n may appear under ! or agg in stratum n+1

Expressive Capability Nothing can do everything. Forms of RA and Datalog can express things the other cannot. Positive Relations Negation Aggregates Recursive Pure Datalog Stratified Datalog Stratified Datalog + agg. Non-recursive Non-recursive Datalog Positive RA RA Extended RA

This Worksheet Part 1: Gradual introduction to datalog Part 2: SQL/RA recap and applied datalog