Query evaluation in recursive databases: bottom-up and top-down reconciled

François Bry
1990 Data & Knowledge Engineering  
It is desirable to answer queries' posed to deductive databases by computing fixpoints because such computations are directly amenable to set-oriented fact processing. However, the classical fixpoint procedures based on bottom-up processing-the naive and semi-naive methods-are rather primitive and often inefficient. In this article, we rely on bottom-up meta-interpretation for formalizing a new fixpoint procedure that performs a different kind of reasoning: We specify a top-down query answering
more » ... method, which we call the Backward Fixpoint Procedure. Then, we reconsider query evaluation methods for recursive databases. First, we show that the methods based on rewriting on the one hand, and the methods based on resolution on the other hand, implement the Backward Fixpoint Procedure. Second, we interpret the rewritings of the Alexander and Magic Set methods as specializations of the Backward Fixpoint Procedure. Finally, we argue that such a rewriting is also needed in a database context for implementing efficiently the resolution-based methods. Thus, the methods based on rewriting and the methods based on resolution implement the same top-down evaluation of the original database rules by means of auxiliary rules processed bottom-up. 0169-023X/90/$03.50 O 1990-Elsevier Science Publishers B.V. (North-Holland) 29(I l'. BiT ' Query evaluation in recursive databases bottom-up from the database rules and facts. Therefore, they do not use the constants occurring in the queries for restricting the search space. In contrast, such a restriction is a by-product of backward -or top-down -reasoning. The rewriting of the Alexander [24] and Magic Set [2, 5] methods aims at achieving the same restriction on the search space with bottom-up reasoning. In this paper, we show that it is possible to keep the advantages of processing queries through fixpoint computations, without necessarily sticking to the basic principle of the naive and semi-naive methods. We specify a new fixpoint query answering procedure, the 'Backward Fixpoint Procedure', which is based on top-down-or backward-reasoning. In other words, we apply fixpoint theory to databases with another operator than the classical immediate consequence operator of van Emden and Kowalski. The Backward Fixpoint Procedure is a sound and complete query answering method for recursive databases. We rely on bottom-up meta-interpretation for formalizing the Backward Fixpoint Procedure, i.e. we specify a top-down evaluation of the database rules in a meta-language by means of rules intended for bottom-up processing. Meta-interpretation is a technique commonly used in Functional and Logic Programming. Although unusual in databases, it is implicit in database systems that store predefined queries. As we show below, bottom-up meta-interpretation permits one to obtain a surprisingly simple specification for the Backward Fixpoint Procedure. This approach can also be applied to specify other advanced fixpoint procedures like top-down meta-interpretation is conventionally applied in logic programming for enhancing the interpreter-see, e.g. [28] . Bottom-up meta-interpretation gives rise for example to specifying fixpoint procedures for querying databases with uncertain values or for performing updates specified on derived relations [B]. Then, we reconsider evaluation methods for recursive databases from the viewpoint of fixpoint computation. Several methods have been proposed for evaluating queries on recursive databases. Those that ensure termination on all recursive databases defining finitely many facts -e.g. function-free databases -follow one or the other of two approaches. The methods of the first type rewrite the database rules and process the rewritten rules bottom-up. The Alexander [24] and Magic Set [2, 5] methods are based on this principle. The second approach is an extension of SLD-Resolution [13, 18] that consists of storing the encountered queries and the proven answers. The ET* and ET"t~rp algorithms [11], OLDT-Resolution [30], QSQ and SLDAL-Resolution [37] , and the RQA/FQI strategy [22] , are methods of the second type. We investigate both types of methods. We show that the methods based on rewriting as well as the methods based on resolution implement the Backward Fixpoint Procedure. In other words, they express the same top-down reasoning principle in different formalisms. Similarities between rewriting-based and resolution-based methods were already observed by many authors. In particular, Beeri and Ramakrishnan showed in [5] that the same strategies -called "sideway information passing strategies' -can be applied to optimize both types of methods. Moreover, Ramakrishnan noticed in [23] that the same propagation of constants is possible with rewriting-based and resolution-based methods. This point was investigated more formally by Ullman in [33] . Commonalities in the inferences of both types of methods were often cited-e.g, in [10, 4~ 38]. Recently, Seki established a one-to-one mapping between the inferences performed by methods of both types [26] . These observations and results are precursors of the study we present here. Examining efficient implementations of the Backward Fixpoint Procedure, we investigate a technique called specialization. Specializing meta-interpreters is a classical way of obtaining efficient procedures from formal specifications -see e.g. [27] . We show that the rewriting of the Alexander and Magic Set methods can be interpreted as a specialization of the Backward Fixpoint Procedure. We argue that this rewriting is also needed in efficient implementations of resolution-based methods. This motivates features of the implementation of SLDAL-
doi:10.1016/0169-023x(90)90017-8 fatcat:uthlb7gvcbdvxpwkxdttaea6lu