}Optimization. Module 11: Optimization of Recursive Queries. Module Outline
|
|
- Daniel Holt
- 5 years ago
- Views:
Transcription
1 Module 11: Optimization of Recursive Queries Module Outline 11.1 Formalisms for recursive queries 11.2 Computing recursive queries 11.3 Partial transitive closures User Query Transformation & Optimization Internal Representation algebraic Logical & Physical DB Schema }Optimization non algebraic Decomposition into Simple Parts Access Path Selection DB Catalog (Statistics, Cost Parameters) Iterative Program DB Access at run time 343
2 11.1 Formalisms for recursive queries Examples for problems requiring recursion: Ancestors: given relation par(p, c) find all the ancestors of person X. (Reachability in or transitive closure of a digraph) Parts explosion: given relation compound(super, sub, count), compute a complete bill of materials needed to produce one part P. (dto., edges labelled, with computation along edges/paths) Path queries: given relation edge(from, to, distance), compute shortest path from A to B. (dto., with an optimization problem) 344
3 Datalog One option for expressing recursive queries is to use DATALOG as the query language. Characteristics of DATALOG are DATALOG is a subset of 1PL (Horn clauses). Horn clauses: CNF formulae with at most one positive literal,e.g. F = (A B) ( C A D) ( A B) D.... rewritten as implications F (B A) (C A D) (A B 0) (1 D).... and finally, in DATALOG notation (cf. PROLOG) A B, D C A, A B, D or, actually A : B. D : C, A. : A, B. D. 345
4 The ancestor problem in DATALOG: (retrieve all the ancestors of john ) anc(a, C) : par(a, C). anc(a, C) : anc(a, P ), par(p, C). query(x) : anc(x, john). The same generation problem in DATALOG: (retrieve all persons in the same generation with john ) sg(x, Y ) : par(xp, X), sg(y P, XP ), par(y P, Y ). sg(x, X). query(x) : sg(john, X). 346
5 Relational algebra with fixed-point operator Relational algebra can be extended by a least-fixed-point operator LF P, that computes the least fixed point of a recursive (algebraic) equation (of the general form x = f (x)). N.B. There are certain restrictions w.r.t. the algebra operators used in a recursive equation, such that the expressions are monotonic, so as to make sure that a (unique) least fixed point exists. (For example: no differences or, in terms of DATALOG: no negation.) Example: the ancestor problem Using the binary operator as a sequence of a join and a projection, e.g., anc(a, C) par(p, C) = π anc.a,par.c (anc anc.c=par.p par), we can express recursive queries over the anc relation as: (retrieve all ancestors of john ) query(x) = σ C=john (LF P ( anc = anc par par )). }{{} rec. equation, whose LFP is anc 347
6 Informal definition of the LF P operator: Iterate the following computation, until no more new tuples are found. anc := par par par (par par) par ((par par) par) par... Since is monotonic and par is finite, termination is guaranteed! We see that or anc = par + = par i i=1 anc = LF P (x = x par par). 348
7 Recursive SQL queries Since the 1999 version, the SQL standard contains recursive unions as a means to express recursion in SQL. The idea essentially follows the DATALOG approach, where one clause defines the initialization (anc(a, C) : par(a, C).) and another one the recursive step (anc(a, C) : anc(a, P ), par(p, C).). I Recursive union in SQL:1999 with recursive table (attr 1,...,attr n) as ( SFW Statement 1 /* initialization */ union all SFW Statement 2 ) /* recursive step */ select [distinct]... from recursive table [where... ] [group by... [having... ] ] [order by... ] 349
8 Example: the ancestor problem (retrieve all the ancestors of john ) with anc (A,C) as ( select P,C from par union all select anc.a, par.c from anc, par where anc.c=par.p ) select A from anc where C= john Remark: While LFP-algebra and DATALOG (due to lack of arithmetics) can express reachability queries only, SQL can also express path queries with computation and some optimization. 350
9 11.2 Computing recursive queries Top-down evaluation (depth first search) A DATALOG program can be evaluated just like any other PROLOG program 1 following the top-down, left-to-right search strategy with backtracking: Horn clauses are considered ordered (from top to bottom), as well as the conjuncts in their righthand sides (left-to-right): Given a goal (such as find A, such that anc(a, john)), the evaluation tries to match the left-hand sides of all clauses (starting top-down) against the goal ( unification ), and then tries to satisfy the conjuncts of matching right-hand sides (sub-goals), proceeding left-to-right. If successful, display variable bindings found (as one result tuple) and wait for user to ask for more. If unsuccessful (or user asks for more), use backtracking to reverse search and try next possibility starting with last decision. 1 syntactically, DATALOG is a subset of PROLOG 351
10 Visualization using Warren s Abstract Machine (WAM) Use boxes to represent evaluation of sub-goals: CALL EXIT FAIL REDO CALL This is the first invocation of the sub-goal, to search for satisfying variable bindings. REDO This is for subsequent calls to find alternative bindings. EXIT This exit returns successful bindings. FAIL This exit signals unsuccessful search. The overall search strategy can be visualized by connecting those boxes according to the initial goal queried and the clauses used. Consider the following example ( geschwister =siblings, elternteil =parent): sibling(x, Y ) : par(p, X), par(p, Y ), X Y. 352
11 ?- geschwister(erika,x). geschwister(k1,k2) :- elternteil(x,k1), elternteil(x,k2), K1 \= K2. elternteil(x1,erika)? elternteil( jens,erika). (K1) elternteil(x1,erika)? elternteil( anna,erika). (K1) elternteil(jens,k2)? elternteil(jens,k2)? FAIL elternteil(jens,k2)? elternteil(anna,k2)? elternteil(jens, elke). (K2,X) elternteil(jens, helga). (K2,X) elternteil(jens, erika). (K2,X) elternteil(anna, elke). (K2,X) erika \= elke? erika \= helga? erika \= erika? erika \= elke? true FAIL true FAIL FAIL true FAIL X = elke ; X = helga ; X = elke ; Observation: Processing proceeds one-record-at-a-time. However, only those records are considered, that really contribute to the result. 353
12 Bottom-up evaluation (breadth first search) The second statement in the loop exploits set-oriented relational processing (esp. joins). 354 In a database context, evaluation using an iteration scheme similar to the informal definition shown above can be promising, since it exploits the set-oriented capabilities of relational query processors (within each iteration step, a join is computed). This evaluation strategy is known as (semi-) naive evaluation or (delta-) iteration in the literature. Semi-Naive Iteration (for the whole ancestor relation) anc 0 := ; 1 := par; i := 1; repeat anc i := anc i 1 i ; i+1 := ( i par) anc i until i+1 =
13 11.3 Partial transitive closures With the least-fixed-point algebra as well as the bottom-up evaluation strategy, we re running into trouble, once we take into account that queries typically ask for ancestors of one (or possibly a few) person(s), not for the complete anc-relation. Recall the LFP-algebra expression mentioned above: query(x) = σ C=john (LF P (anc = anc par par)). Problem: to move the selection σ C= john inside the LFP-operator, we need new algebraic equivalence rules involving σ, LF P,. This is indeed possible and yields: query(x) = LF P (E = E par σ C=john par)), with E = σ C=john anc, which, in terms of DATALOG, corresponds to: anc(john, C) : par(john, C). anc(john, C) : anc(john, P ), par(p, C). query(x) : anc(john, X). N.B. The selection condition has been moved into all iteration steps. 355
14 Magic Set rewriting Goal: devise a (DATALOG) query rewriting method that propagates selections through recursion. Problem: selection predicate changes with each step of the recursion (or iteration), to reflect newly obtained interesting values (the front of the search). Idea: introduce new predicates and rules that collect relevant variable bindings for free variables. Those are called Magic Predicates. Example: reconsider the same generation problem mentioned above: sg(x, Y ) : par(xp, X), sg(y P, XP ), par(y P, Y ). sg(x, X). query(x) : sg(john, X). Starting from the query given, mark predicates, according to which of their variables are free/bound and add magic predicates to propagate bindings.! Restriction: Magic set rewriting only works for linear recursion! 356
15 Definitions 1 Adornment of a predicate: A string of f and b attached to the predicate symbol. The length of that string equals the number of parameters of the predicate. 2 Distinguished Argument of a predicate: a) a constant, b) a variable marked b (in the head predicate 2 of a rule), or c) a variable occuring in a base predicate 3 that has a distinguished argument. 3 Adorned Rule System for a given DATALOG program and query: For each rule and each distinct adornment of its head predicate, generate a new adorned rule a) b for distinguished (bound) arguments, b) f for other (free) arguments, c) mark body predicates 4 of each rule with corresponding adornments. 2 head predicate: the predicate on the left-hand side of a rule 3 base predicate: a predicate that does not occur on the left-hand side of any rule 4 body predicate: the predicates on the right-hand side of a rule 357
16 Example For the query-rule and the recursive sg-rule above, we obtain: sg bf (X, Y ) : par(xp, X), sg f b (Y P, XP ), par(y P, Y ). query f (X) : sg bf (john, X). If we apply the rewriting to all rules with all adornments obtained, we end up with: sg bf (X, Y ) : par(xp, X), sg f b (Y P, XP ), par(y P, Y ). sg f b (X, Y ) : par(xp, X), sg bf (Y P, XP ), par(y P, Y ). sg bf (X, X). sg f b (X, X). query f (X) : sg bf (john, X). In general, the DATALOG program grows exponentially! But, since we distinguish predicates with different adornments, only those really needed are used when evaluating a query. 358
17 Magic Set rewriting continued... After generating the adorned rule system: For each occurence of a derived predicate 5 generate a magic rule. in the body of an adorned rule: For each adorned rule: generate a modified rule. 5 derived predicate: a predicate that occurs on the left-hand side of some rule 359
18 Generating Magic Rules 1 select an adorned predicate P from the body of the rule; 2 delete all other derived predicates from the body of the rule; 3 rename P a to magic P a (a is the adornment of P ) and delete all free variables from its parameter list; 4 delete all unbound base predicates from the body; 5 delete all free variables in the head predicate P0 a to magic P0 a ; 6 exchange magic P a and magic P a 0. and rename the head predicate Example: sg bf (X, Y ) : par(xp, X), sg f b (Y P, XP ), par(y P, Y ). magic sg f b (XP ) : par(xp, X), magic sg bf (X). 360
19 Generating Modified Rules For each rule with head predicate P a : add a magic predicate magic P a (Z) to its body, where Z is the list of bound variables in P a. Example: sg bf (X, Y ) : par(xp, X), sg f b (Y P, XP ), par(y P, Y ). sg bf (X, Y ) : magic sg bf (X), par(xp, X), sg f b (Y P, XP ), par(y P, Y ). Notice how magic sg bf (X) works as a filter to restrict the attention to relevant X-values and how bindings are passed between the body predicates. This has been called sideways information passing in the literature. 361
20 Properties of the Magic Set approach Rather complicated rule rewriting. In general, much larger rule set. Magic Predicates act as filters, such that only relevant data is used in recursion/iteration. Bottom-Up evaluation (e.g., by semi-naive iteration) is typically much faster after this transformation: In parallel to query (or sg) predicate, the magic-predicates are evaluated in each step. Magic predicates are used in selections of the next iterative step. 362
21 The Counting method Idea: a variation of the Magic Set approach. Magic predicates collect data relevant for the next iterative step. Counting predicates collect relevant data and their distance to the starting point of the iteration. Example: Generalized Same Generation problem p(x, Y ) : f lat(x, Y ). p(x, Y ) : up(x, XU), p(y U, XU), down(y U, Y ). query(x) : p(a, X). Magic predicate magic up would collect all up s of a. Counting predicate additionally counts levels above a. 363
22 Counting transformation for the example Rules akin to those for the Magic Set approach lead to: counting(a, 0). counting(x, I) : counting(y, J), up(y, X), I = J + 1. p (Y, I) : counting(x, I), f lat(x, Y ). p (Y, I) : p (Y U, J), down(y U, Y ), I = J 1, J > 0. query(x) : p (X, 0).... each iterative step computes only the next level of relevant data. N.B. collecting X-values for predicate p is not necessary (cf. stack)! counting(a, 0). counting(x, I) : counting(y, J), up(y, X), I = J + 1. p (X, Y, I) : counting(x, I), f lat(x, Y ). p (X, Y, I) : counting(x, I), up(x, XU), p (Y U, XU, J), down(y U, Y ), I = J 1. query(x) : p (a, X, 0).... for this to work, data must not contain cycles! 364
23 Concluding remarks Quite a few other variants have been proposed in the literature (e.g., Reverse Counting, Magic Counting,... ). Extensions can be added to deal with general Horn clauses (including function symbols), e.g., Generalized Magic Sets. Also, more efficient Top-Down evaluation strategies have been developed (e.g., Query/Subquery). Intelligent Top-Down evaluation and clever transformation plus set-oriented Bottom Up evaluation can achieve similar performance. 365
24 Bibliography Bancilhon, F. (1985). Naive evaluation of recursively defined relations. In On Knowledge Base Management Systems, pages Spring-Verlag. Bancilhon, F., Maier, D., Sagiv, Y., and Ullman, J. D. (1986). Magic sets and other strange ways to implement logic programs. In Proc. ACM SIGACT/SIGMOD Symp. on Principles of Database Systems, pages Bancilhon, F. and Ramakrishnan, R. (1986). An amateur s introduction to recursive query processing strategies. In Proc. ACM SIGMOD Conf. on Management of Data, pages 16 52, Washington, DC. Beeri, C. and Ramakrishnan, R. (1987). On the power of magic. In Proc. ACM SIGACT/SIGMOD Symp. on Principles of Database Systems, pages Ceri, S., Gottlob, G., and Tanca, L. (1989). What you always wanted to know about datalog (and never dared to ask). IEEE Trans. Knowl. Data Eng., 1(1): Güntzer, U., Kiessling, W., and Bayer, R. (1987). On the evaluation of recursion in (deductive) database systems by efficient differential fixpoint iteration. In Proc. IEEE Int l Conf. on Data Engineering. Henschen, L. J. and Naqvi, S. A. (1984). On compiling queries in recursive first-order databases. Journal of the ACM, 31(1): Saccà, D. and Zaniolo, C. (1987). Magic counting methods. In Proc. ACM SIGMOD Conference on Management of Data, pages
25 Ullman, J. D. (1985). Implementation of logical query languages for databases. ACM Transactions on Database Systems, 10(3):
}Optimization Formalisms for recursive queries. Module 11: Optimization of Recursive Queries. Module Outline Datalog
Module 11: Optimization of Recursive Queries 11.1 Formalisms for recursive queries Examples for problems requiring recursion: Module Outline 11.1 Formalisms for recursive queries 11.2 Computing recursive
More informationEncyclopedia of Database Systems, Editors-in-chief: Özsu, M. Tamer; Liu, Ling, Springer, MAINTENANCE OF RECURSIVE VIEWS. Suzanne W.
Encyclopedia of Database Systems, Editors-in-chief: Özsu, M. Tamer; Liu, Ling, Springer, 2009. MAINTENANCE OF RECURSIVE VIEWS Suzanne W. Dietrich Arizona State University http://www.public.asu.edu/~dietrich
More informationDATABASE THEORY. Lecture 12: Evaluation of Datalog (2) TU Dresden, 30 June Markus Krötzsch
DATABASE THEORY Lecture 12: Evaluation of Datalog (2) Markus Krötzsch TU Dresden, 30 June 2016 Overview 1. Introduction Relational data model 2. First-order queries 3. Complexity of query answering 4.
More informationDATABASE THEORY. Lecture 15: Datalog Evaluation (2) TU Dresden, 26th June Markus Krötzsch Knowledge-Based Systems
DATABASE THEORY Lecture 15: Datalog Evaluation (2) Markus Krötzsch Knowledge-Based Systems TU Dresden, 26th June 2018 Review: Datalog Evaluation A rule-based recursive query language father(alice, bob)
More informationFoundations of Databases
Foundations of Databases Free University of Bozen Bolzano, 2004 2005 Thomas Eiter Institut für Informationssysteme Arbeitsbereich Wissensbasierte Systeme (184/3) Technische Universität Wien http://www.kr.tuwien.ac.at/staff/eiter
More informationDatalog Evaluation. Linh Anh Nguyen. Institute of Informatics University of Warsaw
Datalog Evaluation Linh Anh Nguyen Institute of Informatics University of Warsaw Outline Simple Evaluation Methods Query-Subquery Recursive Magic-Set Technique Query-Subquery Nets [2/64] Linh Anh Nguyen
More informationLOGIC AND DISCRETE MATHEMATICS
LOGIC AND DISCRETE MATHEMATICS A Computer Science Perspective WINFRIED KARL GRASSMANN Department of Computer Science University of Saskatchewan JEAN-PAUL TREMBLAY Department of Computer Science University
More informationCopyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and
Chapter 6 The Relational Algebra and Relational Calculus Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 Outline Unary Relational Operations: SELECT and PROJECT Relational
More informationRelational Database: The Relational Data Model; Operations on Database Relations
Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview
More informationDeductive Databases. Motivation. Datalog. Chapter 25
Deductive Databases Chapter 25 1 Motivation SQL-92 cannot express some queries: Are we running low on any parts needed to build a ZX600 sports car? What is the total component and assembly cost to build
More informationDatalog Evaluation. Serge Abiteboul. 5 mai 2009 INRIA. Serge Abiteboul (INRIA) Datalog Evaluation 5 mai / 1
Datalog Evaluation Serge Abiteboul INRIA 5 mai 2009 Serge Abiteboul (INRIA) Datalog Evaluation 5 mai 2009 1 / 1 Datalog READ CHAPTER 13 lots of research in the late 80 th top-down or bottom-up evaluation
More informationµz An Efficient Engine for Fixed Points with Constraints
µz An Efficient Engine for Fixed Points with Constraints Kryštof Hoder, Nikolaj Bjørner, and Leonardo de Moura Manchester University and Microsoft Research Abstract. The µz tool is a scalable, efficient
More informationA Logic Database System with Extended Functionality 1
A Logic Database System with Extended Functionality 1 Sang-goo Lee Dong-Hoon Choi Sang-Ho Lee Dept. of Computer Science Dept. of Computer Science School of Computing Seoul National University Dongduk Women
More informationCMPS 277 Principles of Database Systems. https://courses.soe.ucsc.edu/courses/cmps277/fall11/01. Lecture #11
CMPS 277 Principles of Database Systems https://courses.soe.ucsc.edu/courses/cmps277/fall11/01 Lecture #11 1 Limitations of Relational Algebra & Relational Calculus Outline: Relational Algebra and Relational
More informationRelational Databases
Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 49 Plan of the course 1 Relational databases 2 Relational database design 3 Conceptual database design 4
More informationData Integration: Datalog
Data Integration: Datalog Jan Chomicki University at Buffalo and Warsaw University Feb. 22, 2007 Jan Chomicki (UB/UW) Data Integration: Datalog Feb. 22, 2007 1 / 12 Plan of the course 1 Datalog 2 Negation
More informationDATABASE THEORY. Lecture 11: Introduction to Datalog. TU Dresden, 12th June Markus Krötzsch Knowledge-Based Systems
DATABASE THEORY Lecture 11: Introduction to Datalog Markus Krötzsch Knowledge-Based Systems TU Dresden, 12th June 2018 Announcement All lectures and the exercise on 19 June 2018 will be in room APB 1004
More informationA Retrospective on Datalog 1.0
A Retrospective on Datalog 1.0 Phokion G. Kolaitis UC Santa Cruz and IBM Research - Almaden Datalog 2.0 Vienna, September 2012 2 / 79 A Brief History of Datalog In the beginning of time, there was E.F.
More informationData Integration: Logic Query Languages
Data Integration: Logic Query Languages Jan Chomicki University at Buffalo Datalog Datalog A logic language Datalog programs consist of logical facts and rules Datalog is a subset of Prolog (no data structures)
More informationConstraint Solving. Systems and Internet Infrastructure Security
Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Constraint Solving Systems
More informationModule 9: Selectivity Estimation
Module 9: Selectivity Estimation Module Outline 9.1 Query Cost and Selectivity Estimation 9.2 Database profiles 9.3 Sampling 9.4 Statistics maintained by commercial DBMS Web Forms Transaction Manager Lock
More informationRange Restriction for General Formulas
Range Restriction for General Formulas 1 Range Restriction for General Formulas Stefan Brass Martin-Luther-Universität Halle-Wittenberg Germany Range Restriction for General Formulas 2 Motivation Deductive
More informationPart V. Working with Information Systems. Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1
Part V Working with Information Systems Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1 Outline of this part 1 Introduction to Database Languages Declarative Languages Option 1: Graphical
More informationImplementação de Linguagens 2016/2017
Implementação de Linguagens Ricardo Rocha DCC-FCUP, Universidade do Porto ricroc @ dcc.fc.up.pt Ricardo Rocha DCC-FCUP 1 Logic Programming Logic programming languages, together with functional programming
More informationDatabase Theory: Datalog, Views
Database Theory: Datalog, Views CS 645 Mar 8, 2006 Some slide content courtesy of Ramakrishnan & Gehrke, Dan Suciu, Ullman & Widom 1 TODAY: Coming lectures Adding recursion: datalog Summary of Containment
More informationDatabase Theory: Beyond FO
Database Theory: Beyond FO CS 645 Feb 11, 2010 Some slide content based on materials of Dan Suciu, Ullman/Widom 1 TODAY: Coming lectures Limited expressiveness of FO Adding recursion (Datalog) Expressiveness
More informationImproving Query Plans. CS157B Chris Pollett Mar. 21, 2005.
Improving Query Plans CS157B Chris Pollett Mar. 21, 2005. Outline Parse Trees and Grammars Algebraic Laws for Improving Query Plans From Parse Trees To Logical Query Plans Syntax Analysis and Parse Trees
More information2.2.2.Relational Database concept
Foreign key:- is a field (or collection of fields) in one table that uniquely identifies a row of another table. In simpler words, the foreign key is defined in a second table, but it refers to the primary
More informationJohann Eder. Universitat Klagenfurt, Institut fur Informatik. calculus - are actually a subset of rst order predicate logic.
1 Logic and Databases Johann Eder Universitat Klagenfurt, Institut fur Informatik Universitatsstr. 65-67, A-9022 Klagenfurt, Austria eder@i.uni-klu.ac.at Abstract. Logic and databases have gone a long
More informationLecture 1: Conjunctive Queries
CS 784: Foundations of Data Management Spring 2017 Instructor: Paris Koutris Lecture 1: Conjunctive Queries A database schema R is a set of relations: we will typically use the symbols R, S, T,... to denote
More informationFOUNDATIONS OF SEMANTIC WEB TECHNOLOGIES
FOUNDATIONS OF SEMANTIC WEB TECHNOLOGIES RDFS Rule-based Reasoning Sebastian Rudolph Dresden, 16 April 2013 Content Overview & XML 9 APR DS2 Hypertableau II 7 JUN DS5 Introduction into RDF 9 APR DS3 Tutorial
More informationChapter 5: Other Relational Languages.! Query-by-Example (QBE)! Datalog
Chapter 5: Other Relational Languages! Query-by-Example (QBE)! Datalog 5.1 Query-by by-example (QBE)! Basic Structure! Queries on One Relation! Queries on Several Relations! The Condition Box! The Result
More informationImplementation Techniques
Web Science & Technologies University of Koblenz Landau, Germany Implementation Techniques Acknowledgements to Angele, Gehrke, STI Word of Caution There is not the one silver bullet In actual systems,
More informationDatabase Theory VU , SS Introduction to Datalog. Reinhard Pichler. Institute of Logic and Computation DBAI Group TU Wien
Database Theory Database Theory VU 181.140, SS 2018 2. Introduction to Datalog Reinhard Pichler Institute of Logic and Computation DBAI Group TU Wien 13 March, 2018 Pichler 13 March, 2018 Page 1 Database
More informationUniversity of Cape Town
/o,! )' LNEAR LBRARY 0068 1611 ll! 1111111 1 l f Department of Computer Science University of Cape Town Semantic Optimisation in Datalog Programs by Mark P.Wassell A Thesis Prepared Under the Supervision
More informationevaluation using Magic Sets optimization has time complexity less than or equal to a particular
Top-Down vs. Bottom-Up Revisited Raghu Ramakrishnan and S. Sudarshan University of Wisconsin-Madison Madison, WI 53706, USA fraghu,sudarshag@cs.wisc.edu Abstract Ullman ([Ull89a, Ull89b]) has shown that
More informationIntegrating Datalog and Constraint Solving
Integrating Datalog and Constraint Solving Benoit Desouter and Tom Schrijvers Ghent University, Belgium {Benoit.Desouter,Tom.Schrijvers}@UGent.be Abstract. LP is a common formalism for the field of databases
More informationQuery Decomposition and Data Localization
Query Decomposition and Data Localization Query Decomposition and Data Localization Query decomposition and data localization consists of two steps: Mapping of calculus query (SQL) to algebra operations
More informationAn Extended Magic Sets Strategy for a Rule. Paulo J Azevedo. Departamento de Informatica Braga, Portugal.
An Extended Magic Sets Strategy for a Rule language with Updates and Transactions Paulo J Azevedo Departamento de Informatica Universidade do Minho, Campus de Gualtar 4700 Braga, Portugal pja@diuminhopt
More informationTHE RELATIONAL MODEL. University of Waterloo
THE RELATIONAL MODEL 1-1 List of Slides 1 2 The Relational Model 3 Relations and Databases 4 Example 5 Another Example 6 What does it mean? 7 Example Database 8 What can we do with it? 9 Variables and
More informationRecursive query facilities in relational databases: a survey
Recursive query facilities in relational databases: a survey Aleksandra Boniewicz 1, Marta Burzanska 1, Piotr Przymus 1, and Krzysztof Stencel 1,2 1 Faculty of Mathematics and Computer Science, Nicolaus
More informationFoundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution
Foundations of AI 9. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard, Andreas Karwath, Bernhard Nebel, and Martin Riedmiller 09/1 Contents Motivation
More informationPart I Logic programming paradigm
Part I Logic programming paradigm 1 Logic programming and pure Prolog 1.1 Introduction 3 1.2 Syntax 4 1.3 The meaning of a program 7 1.4 Computing with equations 9 1.5 Prolog: the first steps 15 1.6 Two
More informationChapter 6: Bottom-Up Evaluation
6. Bottom-Up Evaluation 6-1 Deductive Databases and Logic Programming (Winter 2009/2010) Chapter 6: Bottom-Up Evaluation Evaluation of logic programs with DB techniques. Predicate dependency graph. Seminaive
More informationAnnouncements. CSCI 334: Principles of Programming Languages. Exam Study Session: Monday, May pm TBL 202. Lecture 22: Domain Specific Languages
Announcements CSCI 334: Principles of Programming Languages Lecture 22: Domain Specific Languages Exam Study Session: Monday, May 14 2-4pm TBL 202 Instructor: Dan Barowy Exercise Domain Specific Languages
More informationChapter 5: Other Relational Languages
Chapter 5: Other Relational Languages Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 5: Other Relational Languages Tuple Relational Calculus Domain Relational Calculus
More informationLogic As a Query Language. Datalog. A Logical Rule. Anatomy of a Rule. sub-goals Are Atoms. Anatomy of a Rule
Logic As a Query Language Datalog Logical Rules Recursion SQL-99 Recursion 1 If-then logical rules have been used in many systems. Most important today: EII (Enterprise Information Integration). Nonrecursive
More informationMathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 37 Resolution Rules
Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras Lecture - 37 Resolution Rules If some literals can be unified, the same algorithm should be able
More informationScreaming Fast Declarative Pointer Analysis
Screaming Fast Declarative Pointer Analysis http://doop.program-analysis.org Martin Bravenboer and Yannis Smaragdakis University of Massachusetts Amherst University of Oregon NEPLS March 5, 2008 overview
More informationA Simple SQL Injection Pattern
Lecture 12 Pointer Analysis 1. Motivation: security analysis 2. Datalog 3. Context-insensitive, flow-insensitive pointer analysis 4. Context sensitivity Readings: Chapter 12 A Simple SQL Injection Pattern
More informationOptimizing Recursive Queries in SQL
Optimizing Recursive Queries in SQL Carlos Ordonez Teradata, NCR San Diego, CA 92127, USA carlos.ordonez@teradata-ncr.com ABSTRACT Recursion represents an important addition to the SQL language. This work
More informationPrinciples of Data Management. Lecture #12 (Query Optimization I)
Principles of Data Management Lecture #12 (Query Optimization I) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Today s Notable News v B+ tree
More informationPart XII. Mapping XML to Databases. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321
Part XII Mapping XML to Databases Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321 Outline of this part 1 Mapping XML to Databases Introduction 2 Relational Tree Encoding Dead Ends
More informationConjunctive queries. Many computational problems are much easier for conjunctive queries than for general first-order queries.
Conjunctive queries Relational calculus queries without negation and disjunction. Conjunctive queries have a normal form: ( y 1 ) ( y n )(p 1 (x 1,..., x m, y 1,..., y n ) p k (x 1,..., x m, y 1,..., y
More informationLogic and its Applications
Logic and its Applications Edmund Burke and Eric Foxley PRENTICE HALL London New York Toronto Sydney Tokyo Singapore Madrid Mexico City Munich Contents Preface xiii Propositional logic 1 1.1 Informal introduction
More informationSAT solver of Howe & King as a logic program
SAT solver of Howe & King as a logic program W lodzimierz Drabent June 6, 2011 Howe and King [HK11b, HK11a] presented a SAT solver which is an elegant and concise Prolog program of 22 lines. It is not
More informationAnnouncements. Relational Model & Algebra. Example. Relational data model. Example. Schema versus instance. Lecture notes
Announcements Relational Model & Algebra CPS 216 Advanced Database Systems Lecture notes Notes version (incomplete) available in the morning on the day of lecture Slides version (complete) available after
More informationQuery Containment for Data Integration Systems
Query Containment for Data Integration Systems Todd Millstein University of Washington Seattle, Washington todd@cs.washington.edu Alon Levy University of Washington Seattle, Washington alon@cs.washington.edu
More informationSemantic Subtyping. Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud)
Semantic Subtyping Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud) http://www.cduce.org/ Semantic Subtyping - Groupe de travail BD LRI p.1/28 CDuce A functional
More informationTerm Algebras with Length Function and Bounded Quantifier Elimination
with Length Function and Bounded Ting Zhang, Henny B Sipma, Zohar Manna Stanford University tingz,sipma,zm@csstanfordedu STeP Group, September 3, 2004 TPHOLs 2004 - p 1/37 Motivation: Program Verification
More informationD2R2: Disk-oriented Deductive Reasoning in a RISC-style RDF Engine
D2R2: Disk-oriented Deductive Reasoning in a RISC-style RDF Engine Mohamed Yahya and Martin Theobald Max-Planck Institute for Informatics, Saarbrücken, Germany {myahya,mtb}@mpi-inf.mpg.de Abstract. Deductive
More informationThe Metalanguage λprolog and Its Implementation
The Metalanguage λprolog and Its Implementation Gopalan Nadathur Computer Science Department University of Minnesota (currently visiting INRIA and LIX) 1 The Role of Metalanguages Many computational tasks
More informationQuery Processing SL03
Distributed Database Systems Fall 2016 Query Processing Overview Query Processing SL03 Distributed Query Processing Steps Query Decomposition Data Localization Query Processing Overview/1 Query processing:
More informationPrinciples of Programming Languages
Principles of Programming Languages Lesson Collaboration 22 An Introduction and Management to Logic Programming Dana Fisman Logic Programming ( Pure Prolog ) www.cs.bgu.ac.il/~ppl172 1 Review of Last Lecture
More informationThe CORAL Deductive System
VLDB Journal,2, 161-210 (1994), Kotagiri Ramamohanarao, Editor @VLDB 161 The CORAL Deductive System Raghu Ramakrishnan, Divesh Srivastava, S. Sudarshan, and Praveen Seshadri Received Aprig 1993; revised
More informationElement Algebra. 1 Introduction. M. G. Manukyan
Element Algebra M. G. Manukyan Yerevan State University Yerevan, 0025 mgm@ysu.am Abstract. An element algebra supporting the element calculus is proposed. The input and output of our algebra are xdm-elements.
More informationDatalog Recursive SQL LogicBlox
CS 500: Fundamentals of Databases Datalog Recursive SQL LogicBlox supplementary material: Foundations of Databases by Abiteboul, Hull, Vianu, Ch. 12 class notes slides are based on teaching materials by
More informationFoundations of SPARQL Query Optimization
Foundations of SPARQL Query Optimization Michael Schmidt, Michael Meier, Georg Lausen Albert-Ludwigs-Universität Freiburg Database and Information Systems Group 13 th International Conference on Database
More informationOperational Semantics
15-819K: Logic Programming Lecture 4 Operational Semantics Frank Pfenning September 7, 2006 In this lecture we begin in the quest to formally capture the operational semantics in order to prove properties
More informationCS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #10: Query Processing
CS 4604: Introduction to Database Management Systems B. Aditya Prakash Lecture #10: Query Processing Outline introduction selection projection join set & aggregate operations Prakash 2018 VT CS 4604 2
More informationOptimization of Nested Queries in a Complex Object Model
Optimization of Nested Queries in a Complex Object Model Based on the papers: From Nested loops to Join Queries in OODB and Optimisation if Nested Queries in a Complex Object Model by Department of Computer
More informationOther Relational Languages
C H A P T E R 5 Other Relational Languages Exercises 5.1 Answer: The participated relation relates car(s) and accidents. Assume the date attribute is of the form YYYY-MM-DD. a. Find the total number of
More informationDatalog. Susan B. Davidson. CIS 700: Advanced Topics in Databases MW 1:30-3 Towne 309
Datalog Susan B. Davidson CIS 700: Advanced Topics in Databases MW 1:30-3 Towne 309 http://www.cis.upenn.edu/~susan/cis700/homepage.html 2017 A. Alawini, S. Davidson Homework for this week Sign up to present
More information1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.
1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered
More informationOverview of DB & IR. ICS 624 Spring Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa
ICS 624 Spring 2011 Overview of DB & IR Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1/12/2011 Lipyeow Lim -- University of Hawaii at Manoa 1 Example
More informationI. Khalil Ibrahim, V. Dignum, W. Winiwarter, E. Weippl, Logic Based Approach to Semantic Query Transformation for Knowledge Management Applications,
I. Khalil Ibrahim, V. Dignum, W. Winiwarter, E. Weippl, Logic Based Approach to Semantic Query Transformation for Knowledge Management Applications, Proc. of the International Conference on Knowledge Management
More informationA Parameterised Module System for Constructing Typed Logic Programs
A Parameterised Module System for Constructing Typed Logic Programs P.M. Hill* Division of Artificial Intelligence, School of Computer Studies University of Leeds, Leeds, LS2 9JT, UK hill@scs.leeds.ac.uk
More informationCMP-3440 Database Systems
CMP-3440 Database Systems Relational DB Languages Relational Algebra, Calculus, SQL Lecture 05 zain 1 Introduction Relational algebra & relational calculus are formal languages associated with the relational
More informationBoolean Functions (Formulas) and Propositional Logic
EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving Part I: Basics Sanjit A. Seshia EECS, UC Berkeley Boolean Functions (Formulas) and Propositional Logic Variables: x 1, x 2, x 3,, x
More informationInformation Systems (Informationssysteme)
Information Systems (Informationssysteme) Jens Teubner, TU Dortmund jens.teubner@cs.tu-dortmund.de Summer 2016 c Jens Teubner Information Systems Summer 2016 1 Part V The Relational Data Model c Jens Teubner
More informationVirtual views. Incremental View Maintenance. View maintenance. Materialized views. Review of bag algebra. Bag algebra operators (slide 1)
Virtual views Incremental View Maintenance CPS 296.1 Topics in Database Systems A view is defined by a query over base tables Example: CREATE VIEW V AS SELECT FROM R, S WHERE ; A view can be queried just
More informationAnnoucements. Where are we now? Today. A motivating example. Recursion! Lecture 21 Recursive Query Evaluation and Datalog Instructor: Sudeepa Roy
Annoucements CompSci 516 Database Systems Lecture 21 Recursive Query Evaluation and Datalog Instructor: Sudeepa Roy HW3 due Monday 11/26 Next week practice pop-up quiz on transactions (all lectures) 1
More informationCSE 544: Principles of Database Systems
CSE 544: Principles of Database Systems Semijoin Reductions Theory Wrap-up CSE544 - Spring, 2012 1 Announcements Makeup lectures: Friday, May 18, 10:30-11:50, CSE 405 Friday, May 25, 10:30-11:50, CSE 405
More informationEvaluating XPath Queries
Chapter 8 Evaluating XPath Queries Peter Wood (BBK) XML Data Management 201 / 353 Introduction When XML documents are small and can fit in memory, evaluating XPath expressions can be done efficiently But
More informationProlog-2 nd Lecture. Prolog Predicate - Box Model
Prolog-2 nd Lecture Tracing in Prolog Procedural interpretation of execution Box model of Prolog predicate rule How to follow a Prolog trace? Trees in Prolog use nested terms Unification Informally Formal
More informationEECS 219C: Formal Methods Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley
EECS 219C: Formal Methods Boolean Satisfiability Solving Sanjit A. Seshia EECS, UC Berkeley The Boolean Satisfiability Problem (SAT) Given: A Boolean formula F(x 1, x 2, x 3,, x n ) Can F evaluate to 1
More informationChoice Logic Programs and Nash Equilibria in Strategic Games
Choice Logic Programs and Nash Equilibria in Strategic Games Marina De Vos and Dirk Vermeir Dept. of Computer Science Free University of Brussels, VUB Pleinlaan 2, Brussels 1050, Belgium Tel: +32 2 6293308
More informationEvaluation of SPARQL Property Paths via Recursive SQL
Evaluation of SPARQL Property Paths via Recursive SQL Nikolay Yakovets, Parke Godfrey, and Jarek Gryz Department of Computer Science and Engineering, York University, Canada {hush,godfrey,jarek}@cse.yorku.ca
More informationLogical reasoning systems
Logical reasoning systems Theorem provers and logic programming languages Production systems Frame systems and semantic networks Description logic systems CS 561, Session 19 1 Logical reasoning systems
More informationDirected Graphical Models (Bayes Nets) (9/4/13)
STA561: Probabilistic machine learning Directed Graphical Models (Bayes Nets) (9/4/13) Lecturer: Barbara Engelhardt Scribes: Richard (Fangjian) Guo, Yan Chen, Siyang Wang, Huayang Cui 1 Introduction For
More informationOPTIMIZING RECURSIVE INFORMATION GATHERING PLANS. Eric M. Lambrecht
OPTIMIZING RECURSIVE INFORMATION GATHERING PLANS by Eric M. Lambrecht A Thesis Presented in Partial Fulfillment of the Requirements for the Degree Master of Science ARIZONA STATE UNIVERSITY December 1998
More informationIndex-Driven XQuery Processing in the exist XML Database
Index-Driven XQuery Processing in the exist XML Database Wolfgang Meier wolfgang@exist-db.org The exist Project XML Prague, June 17, 2006 Outline 1 Introducing exist 2 Node Identification Schemes and Indexing
More informationDenotational Semantics. Domain Theory
Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning
More informationQuerying Complex Graphs
Querying Complex Graphs Yanhong A. Liu and Scott D. Stoller Computer Science Department, State University of New York at Stony Brook Stony Brook, NY 11794 {liu,stoller}@cs.sunysb.edu Abstract. This paper
More informationSoftware Paradigms (Lesson 7) Logic Programming & Software Engineering
Software Paradigms (Lesson 7) Logic Programming & Software Engineering Table of Contents 1 Goals (Queries)... 2 1.1 Verifier Goal... 3 1.2 Finder Goals... 4 1.3 Doer Goals... 5 2 Some Implementation Issues...
More informationCSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li
CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Main Goal of Algorithm Design Design fast
More informationDesigning Views to Answer Queries under Set, Bag,and BagSet Semantics
Designing Views to Answer Queries under Set, Bag,and BagSet Semantics Rada Chirkova Department of Computer Science, North Carolina State University Raleigh, NC 27695-7535 chirkova@csc.ncsu.edu Foto Afrati
More informationLecture 6: Arithmetic and Threshold Circuits
IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Advanced Course on Computational Complexity Lecture 6: Arithmetic and Threshold Circuits David Mix Barrington and Alexis Maciel July
More informationCS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting
CS2 Algorithms and Data Structures Note 10 Depth-First Search and Topological Sorting In this lecture, we will analyse the running time of DFS and discuss a few applications. 10.1 A recursive implementation
More informationKeyword query interpretation over structured data
Keyword query interpretation over structured data Advanced Methods of IR Elena Demidova Materials used in the slides: Jeffrey Xu Yu, Lu Qin, Lijun Chang. Keyword Search in Databases. Synthesis Lectures
More information