# Nonrecursive incremental evaluation of Datalog queries

- 96 Downloads
- 16 Citations

## Abstract

We consider the problem of repeatedly evaluating the same (computationally expensive) query to a database that is being updated between successive query requests. In this situation, it should be possible to use the difference between successive database states and the answer to the query in one state to reduce the cost of evaluating the query in the next state. We use nonrecursive Datalog (which are unions of conjunctive queries) to compute the differences, and call this process “incremental query evaluation using conjunctive queries”. After formalizing the notion of incremental query evaluation using conjunctive queries, we give an algorithm that constructs, for each regular chain query (including transitive closure as a special case), a nonrecursive Datalog program to compute the difference between the answer after an update and the answer before the update. We then extend this result to weakly regular queries, which are regular chain programs augmented with conjunctive queries having the so-called Cartesian-closed increment property, and to the case of unbounded-set insertions where the sets are binary Cartesian products. Finally, we show that the class of conjunctive queries with the Cartesian-closed increment property is decidable.

## Keywords

Neural Network Artificial Intelligence Complex System Nonlinear Dynamics Transitive Closure## Preview

Unable to display preview. Download preview PDF.

## References

- [1]F. Afrati and S.S. Cosmadakis, Expressiveness of restricted recursive queries,
*Proc. ACM SIGACT Symp. on the Theory of Computing*(1989) pp. 113–126.Google Scholar - [2]K.R. Apt, H.A. Blair and A. Walker, Towards a theory of declarative knowledge, in:
*Foundations of Deductive Databases and Logic Programming*, ed. J. Minker (Morgan Kaufmann, 1988) pp. 89–148.Google Scholar - [3]S. Abiteboul, R. Hull and V. Vianu, Database theory: From A to F, manuscript (1994).Google Scholar
- [4]K.R. Apt and J.-M. Pugin, Maintenance of stratified databases viewed as a belief revision system,
*Proc. 6th ACM Symp. on Principles of Database Systems*(1987) pp. 136–145.Google Scholar - [5]A. Aho and J. Ullman, Universality of data retrieval languages,
*Proc. ACM Symp. on Principles of Programming Languages*(1979) pp. 110–120.Google Scholar - [6]F. Bancilhon, Naive evaluation of recursively defined relations, in:
*On Knowledge Base Management Systems: Integrating Artificial Intelligence and Database Technologies*, eds. M.L. Brodie and J. Mylopoulos (Springer, 1985).Google Scholar - [7]V. Breazu-Tannen, P. Buneman and L. Wong, Naturally embedded query languages,
*Proc. 1992 Int. Conf. on Database Theory*, LNCS 646 (Springer, 1992) pp. 140–154.Google Scholar - [8]F. Bancilhon, D. Maier, Y. Sagiv and J.D. Ullman, Magic sets and other strange ways to implement logic programs,
*Proc. 5th ACM Symp. on Principles of Database Systems*(1986) pp. 1–15.Google Scholar - [9]F. Bry, H. Decker and R. Manthey, A uniform approach to constraint satisfaction and constraint satisfiability in deductive databases,
*Proc. 1st Int. Conf. on Extending Database Technology*(1988) pp. 488–505.Google Scholar - [10]A.L. Buchsbaum, P.C. Kanellakis and J.S. Vitter, A data structure for arc insertion and regular path finding,
*Proc. ACM-SIAM Symp. on Discrete Algorithms*(1990).Google Scholar - [11]A. Chandra and P. Merlin, Optimal implementation of conjunctive queries in relational data bases,
*Proc. ACM SIGACT Symp. on the Theory of Computing*(1977) pp. 77–90.Google Scholar - [12]G. Dong, On Datalog linearization of chain queries, in:
*Theoretical Studies in Computer Science*, ed. J.D. Ullman (Academic Press, 1991) pp. 181–206.Google Scholar - [13]G. Dong, Datalog expressiveness of chain queries: Grammar tools and characterizations,
*Proc. 11th ACM Symp. on Principles of Database Systems*(1992) pp. 81–90.Google Scholar - [14]G. Dong and J. Su, First-order on-line computation of transitive closure queries,
*Proc. 16th Australian Computer Science Conf.*(1993) pp. 721–729.Google Scholar - [15]G. Dong and J. Su, First-order incremental evaluation of Datalog queries,
*Proc. 4th Int. Workshop on Database Programming Languages*(1993).Google Scholar - [16]G. Dong and R. Topor, Incremental evaluation of Datalog queries,
*Proc. Int. Conf. on Database Theory*, LNCS 636 (Springer, 1992) pp. 282–296.Google Scholar - [17]A. Gupta, D. Katiyar and I.S. Mumick, Maintaining views incrementally,
*Proc. ACM SIGMOD Conf.*, pp. 157–166.Google Scholar - [18]G.G. Hillerbrand, P.C. Kanellakis, H.G. Mairson and M.Y. Vardi, Tools for Datalog boundedness,
*Proc. 10th ACM Symp. on Principles of Database Systems*(1991) pp. 1–12.Google Scholar - [19]G. Hillebrand, P. Kanellakis, H. Mairson and M. Vardi, Undecidable boundedness problems for Datalog programs, Technical Report RJ 8739, IBM Almaden Research Center, San Jose, CA (1992).Google Scholar
- [20]T. Ibaraki and N. Katoh, On-line computation of transitive closure of graphs, Inf. Process. Lett. 16(1983)95–97.Google Scholar
- [21]G.F. Italiano, Amortized efficiency of a path retrieval data structure, Theor. Comp. Sci. 48(1986)273–281.Google Scholar
- [22]Y. Ioannidis, A time bound on the materialization of some recursively defined views,
*Proc. Int. Conf. on Very Large Data Bases*(1985).Google Scholar - [23]D. Jacobs and R. Hull, Database programming with delayed updates,
*Proc. 3rd Int. Workshop on Database Programming Languages*(1991) pp. 416–428.Google Scholar - [24]H. Jakobsson, On materializing views and on-line queries,
*Proc. Int. Conf. on Database Theory*, LNCS 646 (Springer, 1992) pp. 407–420.Google Scholar - [25]V. Küchenhoff, On the efficient computation of the difference between consecutive database states, in:
*Proc. 2nd Int. Conf. on Deductive Object-Oriented Databases*, eds. C. Delobel, M. Kifer and Y. Masunaga, LNCS 566 (Springer, 1991) pp. 478–502.Google Scholar - [26]J. La Poutre and J. van Leeuwen, Maintenance of transitive closures and transitive reductions of graphs, Technical Report RUU-CS-87-25, Department of Computer Science, University of Utrecht, The Netherlands (1987). An extended abstract of this paper appeared in LNCS 314, pp. 106–120.Google Scholar
- [27]J.W. Lloyd and J.C. Shepherdson, Partial evaluation logic programming, J. Logic Program. 11(1991)217–242.Google Scholar
- [28]J.W. Lloyd, E.A. Sonenberg and R.W. Topor, Integrity constraint checking in stratified databases, J. Logic Program. 4(1987)331–343.Google Scholar
- [29]J.-M. Nicolas, Logic for improving integrity checking in relational data bases, Acta Inf. 18(1982)227–253.Google Scholar
- [30]X. Qian, On the expressive power of the bounded iteration construct,
*Proc. 2nd Int. Workshop on Database Programming Languages*(1989) pp. 411–421.Google Scholar - [31]J.D. Ullman,
*Principles of Database and Knowledge-Base Systems*, Vols. I and II (Computer Science Press, 1989).Google Scholar - [32]M.H. van Emden and R.A. Kowalski, The semantics of predicate logic as a programming language, J. ACM 23(1976)733–742.Google Scholar
- [33]M. Vardi, Decidability and undecidability results for boundedness of linear recursive programs,
*Proc. ACM Symp. on Principles of Database Systems*(1988) pp. 341–351.Google Scholar - [34]O. Wolfson, H.M. Dewan, S.J. Stolfo and Y. Yemini, Incremental evaluation of rules and its relationship to parallelism,
*Proc. ACM SIGMOD Conf.*(1991) pp. 78–87.Google Scholar