Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Rivero L.Encyclopedia of database technologies and applications.2006

.pdf
Скачиваний:
14
Добавлен:
23.08.2013
Размер:
23.5 Mб
Скачать

way that they behave as different replication methods, depending on the system configuration or the application requirements. However, such solutions are not yet available in commercial database management systems.

CONCLUSION

To my knowledge, this article is the first to evaluate all the most commonly used replication methods. The replication methods are grouped into types, and two methods within each group are evaluated. Tables may be fragmented, and replication can be optimized by selecting the best replication method for each fragment. However, inconsistencies and anomalies may complicate the selection of replication methods, as countermeasures against anomalies should be selected per application/system and not per fragment, as described by Frank and Zahle (1998).

REFERENCES

Berenson, H., Bernstein, P., Gray, J., Melton, J., O’Neil, E., & O’Neil, P. (1995). A critique of ANSI SQL isolation levels. Proceedings of the ACM SIGMOD Conference.

Breibart, Y., Garcia-Molina, H., & Silberschatz, A. (1992). Overview of multidatabase transaction management. VLDB Journal, 2, 181-239.

Coulouris, G., Dollimore, J., & Kindberg, T. (2001). Distributed systems concepts and design. Addison-Wesley.

Frank, L. (1999). Evaluation of the basic remote backup and replication methods for high availability databases.

Software - Practice & Experience, 29(15), 1339-1353.

Frank, L. (2004), Architecture for integration of distributed erp systems and e-commerce systems. Industrial Management and Data Systems, 104(5), 418-429.

Frank, L., & Zahle, T. (1998). Semantic ACID properties in multidatabases using remote procedure calls and update propagations. Software - Practice & Experience, 28, 77-98.

Gallersdörfer, R., & Nicola, M. (1995). Improving performance in replicated databases through relaxed coherency.

Proceedings of the 21st VLDB Conference.

Garcia-Molina, H., & Polyzois, C. (1990). Issues in disaster recovery. IEEE Compcon. (pp. 573-577). New York: IEEE.

Garcia-Molina, H., & Salem, K. (1987). Sagas. Proceedings of the ACM SIGMOD Conference.

Replication Methods and Their Properties

Gray, J., & Reuter, A. (1993). Transaction processing. Morgan Kaufman.

Hadzilacos, V., & Toueg, S. (1993). Fault-tolerant broadcasts and related problems. In S. Mullender (Ed.), Distributed systems (pp. 97-145). Addison-Wesley.

Humborstad, R., Sabaratnam, M., Hvasshovd, S., & Torbjornsen, O. (1997). 1-Safe algorithms for symmetric site configurations. Proceedings of the 23rd VLDB Conference.

Irún, L., Muñoz, F. D., & Bernabéu, J. (2003). An improved optimistic and fault-tolerant replication protocol. Lecture Notes in Computer Science, 2822, 188-200.

Mehrotra, S., Rastogi, R., Korth, H., & Silberschatz, A. (1992). A transaction model for multi-database systems. Proceedings of the International Conference on Distributed Computing Systems.

Polyzois, C., & Garcia-Molina, H. (1994). Evaluation of remote backup algorithms for transaction-process- ing systems. ACM TODS, 19(3), 423-449.

Weikum, G., & Schek, H. (1992). Concepts and applications of multilevel transactions and open nested transactions. In A. Elmagarmid (Ed.), Database transaction models for advanced applications (pp. 515-553). Morgan Kaufmann.

Wiesmann, M., Pedone, F., Schiper, A., Kemme, B. & Alonso, G. (2000). Understanding replication in databases and distributed systems. Proceedings of the 20th

International Conference on Distributed Computing Systems, Taipei, Taiwan, Republic of China.

Zhang, A., Nodine, M., Bhargava, B., & Bukhres, O. (1994). Ensuring relaxed atomicity for flexible transactions in multidatabase systems. Proceedings of the ACM SIGMOD Conference.

KEY TERMS

0-Safe Designs: Replication methods where none of the copies are consistent and up-to-date.

1-Safe Designs: Replication methods where 1 primary copy is consistent and up-to-date.

Availability of Data: The probability of having access to the data. Replication will normally increase data availability.

Caching: Replication methods where access to frequently used data is optimized. In remote caching, a

560

TEAM LinG

Replication Methods and Their Properties

primary copy of the frequently used data is normally stored on a very fast medium to optimize access to data. In local caching, an often inconsistent secondary copy of the frequently used data is stored in or close to the location of some users to optimize their access to the data.

Disaster Recovery: Recovery in a situation where both the current database and its log-files have been destroyed.

Failure Recovery: Recovery in a situation where log-files and the current database or an old database copy are available.

Mirroring: Replication methods where all updates to a logical disk volume are copied by the operating system to two or more physical disk volumes.

n-Safe Designs: Replication methods where all n copies are consistent and up-to-date.

Read Performance: The maximum number of read operations per time unit. Replication will normally in- 4 crease read performance.

Replication Method: A method for managing redundant data in such a way that a system can be optimized in some way.

Write Performance: The maximum number of write operations per time unit. Replication will normally decrease write performance and give rise to a possible of inconsistency between the replicated data.

ENDNOTES

1The probability of lost data as a function of the probability, say p, of a local disaster.

2Logging of the update transactions in the locations of the clients.

3The availability as a function of the probability, say q, of a local site failure.

561

TEAM LinG

562

Rewriting and Efficient Computation of Bound

Disjunctive Datalog Queries

Sergio Greco

DEIS Università della Calabria, Italy

Ester Zumpano

DEIS Università della Calabria, Italy

INTRODUCTION

A strong interest in enhancing Datalog programs by the capability of disjunction emerged in several areas, such as databases, artificial intelligence, logic programming, and so forth (Lobo, Minker & Rajasekar, 1992). Disjunctive rules have been profitably used in several contexts including knowledge representation, databases querying, and representation of incomplete information (Eiter, Gottlob & Mannila, 1997a; Gelfond & Lifschitz, 1991). Most of the works on disjunction are concerned with the definition of intuitive and expressive semantics, which are commonly based on the paradigm of minimal models (Abiteboul, Hull & Vianu, 1995; Lobo et al., 1992; Ullman, 1989).

Disjunction in the head of rules increases the expressive power of the language but makes the computation of queries very difficult, as it allows the presence of multiple models whose number is generally exponential with respect to the size of the input (Abiteboul et al., 1995; Eiter et al., 1997a).

Therefore, a great interest has been devoted to the definition of efficient algorithms for both computing the semantics of programs and answering queries.

Most of the research has concentrated on the definition of efficient fixpoint algorithms computing the semantics of programs, and the more effective proposals are based on the evaluation of the (intelligent) ground instantiation of programs and on the use of heuristics (Leone, Rullo & Scarcello, 1997). However, different from standard datalog, for disjunctive queries, there are few effective methodologies which systematically utilize the query to propagate bindings into the body of the rules to avoid computing all the models of the program.

The following example taken from Greco (2003), shows a program in which only a strict subset of the minimal models needs to be considered to answer the query.

Example 1. Consider the disjunctive program P1 consisting of the following rule:

p(X) q(X) ¬a(X,Y)

and a database D consisting of the set of facts {a(1,2),a(2,3),..., a(k,k+1)}. Consider now a query asking if there is some model for P D containing the atom p(1). A “brute force” approach, based on an exhaustive search of the minimal models of P D, would consider 2k minimal models.

However, to answer the query, we could only consider the ground rule: p(1) q(1)¬a(1,2) and, therefore, only two minimal (partial) (for partial model we intend a subset of the model containing all the atoms necessary to answer the query) models: M1 = { p(1) } D and M2 = { q(1) }.

From the above example, it is evident that using the query goal to reduce the size and the number of models to be considered for answering the query is necessary.

Constraints play an active role in the deductive database process as they model the interaction among data and define properties that have to be satisfied by models.

Thus, this article explores the efficient computation of bound queries over disjunctive Datalog programs enriched with constraints.

The technique here proposed is very relevant for the optimization of queries expressing hard problems. Indeed, the usual way of expressing declaratively hard problems, such as NP problems and problems in the second level of the polynomial hierarchy, is based on the guess-and-check technique, where the guess part is expressed by means of disjunctive rules, and the check part is expressed by means of constraints. However, as shown by the following example, the presence of constraints reduces the number of feasible models but could increase both the number of ground rules and the number of (partial) models to be considered for answering the query.

Example 2. Consider the query goal p(1) over the disjunctive program P2 consisting of the rule in the above example plus the following constraint (a rule with empty head which is true if the body is false)

¬p(X), a(X,Y), q(Y), X 1.

Copyright © 2006, Idea Group Inc., distributing in print or electronic forms without written permission of IGI is prohibited.

TEAM LinG

Rewriting and Efficient Computation of Bound Disjunctive Datalog Queries

To answer the query, we have to consider other than the ground rule:

r1: p(1) q(1) ¬ a(1,2). also the ground rule: r2: p(2) q(2) ¬ a(2,3).

as the atom p(1) in the head of the rule r1 is influenced by the atom q(2) through the ground constraint c1

p(1), a(1,2), q(2), 1 ≤ 1.

Consequently, there are three stable models to be considered:

N1 = { p(1), p(2) } D,

N2 = { q(1), p(2) } D, and

N3 = { q(1), q(2) } D.

The interpretation { p(1), q(2) } D is not a model as it does not satisfy the constraint.

The above example shows the necessity of an effective methodology that uses the properties specified by the constraints and the query goal in order to compute correct answers avoiding the evaluation of useless models. However, in the presence of constraints, we have to consider ground rules defining atoms on which the query goal depends on (both through standard rules and constraints), but also to check that constraints are satisfied by the whole set of ground rules.

BACKGROUND

In the literature, different approaches have been proposed for the efficient bottom-up evaluation of queries, for example, the Magic set (Bancilhon et al., 1986), the Counting (Beeri & Ramakrishnan, 1991), and the supplementary magic set and other specialized rewriting techniques (Beeri & Ramakrishnan, 1991; Greco, Saccà & Zaniolo, 1995; Ramakrishnan et al., 1993; Ullman, 1989). The key idea of all these techniques consists in the rewriting of deductive rules with respect to the query goal to answer the query without actually computing irrelevant facts. In this section, we recall the magicset rewriting technique for Datalog queries as its generality and efficiency makes of this approach a kind of standard in the field.

Although the magic-set can be applied to general Datalog queries, for the sake of simplicity, we present here the technique for linear programs, that is, programs whose rules contain at most one body predicate mutually recursive with the head predicate.

The magic-set method consists of three separate steps:

4

An Adornment step in which the relationship between a bound argument in the rule head and the bindings in the rule body is made explicit.

A Generation step in which the adorned program is used to generate the magic rules which simulate the top-down evaluation scheme.

A Modification step in which the adorned rules are modified by the magic rules generated in Step 2; these rules will be called modified rules.

An adorned program Pb is a program whose predicate symbols have associated a string a defined on the alphabet {b,f} of length equal to the arity of the predicate. A character b (resp. f) in the i-th position of the adornment associated with a predicate p means that the i-th argument of p is bound (resp. free).

The adornment step consists in generating a new program whose predicates are adorned. Given a rule r and an adornment a of the rule head, the adorned version of r is derived as follows:

Identify the distinctive arguments of the rules: an

argument is distinctive if it is bound in the adornment α, is a constant or appears in a base predicate of the rule-body which includes an adornment argument;

Assume that the distinctive arguments are bound and use this information in the adornment of the derived predicates in the rule body.

Adornments containing only f symbols can be omitted.

Given a query Q=<q(T),P> and letting α be the adornment associated with q(T), the set of adorned rules for Q is generated by (1) computing the adorned version of the rules defining q and (2) generating, for each new adorned predicate pαintroduced in the previous step, the adorned version of the rules defining p w.r.t. α; Step 2 is repeated until no new adorned predicate is generated.

The second step of the process consists in using the adorned program for the generation of the magic rules. For each of the adorned predicates in the body of the adorned rule:

Eliminate all the derived predicates in the rule body which are not mutually recursive with the rule head;

Replace the derived predicates symbol pα with magic_pα and eliminate the variables which are free w.r.t. α;

Replace the head predicates symbol qαwith magic_qα and eliminate the variables which are free w.r.t. α; and

563

TEAM LinG

Rewriting and Efficient Computation of Bound Disjunctive Datalog Queries

Interchange the transformed head and derived predicate in the body.

Finally, the modification step of an adorned rule is performed as follows: for each adorned rule whose head is pα(X), where X is a list of variables, extend the rule body with magic_pα (X’) where X’ is the list of variables in X which are bound w.r.t. α.

Example 3. Consider the query Q3 = < { p(1,C)}, P3> where P3 is defined as:

p(X,C) ¬q(X,2,C). q(X,Y,C) ¬a(X,Y,C).

q(X,Y,C) ¬ b(X,Y,Z,W), q(Z,W,D), c(D,C).

The adorned version of P3 w.r.t. the query goal p(1,C)

is:

pbf(X,C) ¬ qbbf (X,2,C). qbbf (X,Y,C) ¬ a(X,Y,C).

qbbf (X,Y,C) ¬ b(X,Y,Z,W), qbbf (Z,W,D), c(D,C).

The rewritten query is Q’3 = < pbf (1,C)},P’3> where P’3 is as follows:

magic_pbf (1).

magic_qbbf (X,2) ¬ magic_ pbf(X).

magic_ qbbf (Z,W) ¬ magic_qbf (X,Y), b(X,Y,Z,W).

pbf (X,C) ¬ magic_pbf (X), qbbf (X,2,C). qbbf (X,Y,C) ¬ magic_qbbf (X,Y), a(X,Y,C).

qbbf (X,Y,C) ¬ magic_qbbf(X,Y), b(X,Y,Z,W), qbbf (Z,W,D), c(D,C).

Note that the first set of rules consists of the magic rules generated in the second step, while the second set of rules consists of the modified rules.

Observe that, although the technique here presented applies only to negation free linear programs, the magicset rewriting is general and can also be applied to nonlinear programs with some form of negation (e.g., stratified negation) where bindings are also propagated through derived predicates (Beeri & Ramakrishnan, 1991).

Let Q=<G,P> be a query, then Magic(Q) denotes the query derived from Q by applying the magic-set method. The query Magic(Q) will be also denoted as <Gα, magic(G,P)> where Gα denotes the adorned version of G, whereas magic(G,P) denotes the rewriting of P w.r.t. the goal G.

The rewritten program consists of two distinct sets of rules: a set of new rules (generated in Step 2), called magic rules, and the set of modified rules (generated in Step 3) which is derived from the set of rules in the source

program. The adorned rules generated in Step 1 are denoted by Adorn(G,P).

BINDING PROPAGATION AND CONSTRAINTS

In this section, we present a technique for propagating bindings into DatalogÚ queries with strong constraints, that is, classical constraints that have to be satisfied in each model. A constraint is a simple and powerful form of unstratified negation and every constraint of the form ¬ B is equivalent, under total stable model semantics to a standard rule of the form p ¬ ¬p, B where p is a new predicate symbol. The advantage of using constraints instead of unstratified negation is that they are highly expressive (disjunctive Datalog with constraints has the same expressive power of disjunctive Datalog with unstratified negation (Flesca et al., 2003)), and they have a simple and intuitive semantics (programs with unstratified negation are neither intuitive nor easily optimiziable).

Despite standard Datalog, in which we propagate bindings from the head of rules into the body, the problem with constraint rules is that we need the bindings to be propagated also through the constraints. For instance, if we are interested in knowing whether p(1) is true in a program where there is the constraint ¬ p(X), q(X), then we also need to evaluate the truth value of q(1).

Thus, the truth value of each ground atom in a constraint depends on the truth value of the other atoms appearing in the same ground constraint, and, hence, in a more abstract perspective, constraint rules behave in a similar manner as disjunctive rules when propagating bindings into their heads.

In the following, a Datalog program P will be denoted by a pair (PR, PC), where PR is a not the empty set of positive disjunctive rules, and PC is a set of positive constraints; moreover, by following the same guidelines of the previous section, we shall introduce the technique and the main results by using a running example.

Example 4. We are given the query <2col(1,2),Coloring>, checking whether a graph is 3-colorable and whether colors red and blue can be assigned to nodes 1 and 2 respectively. The program COLORING consists of the following rules:

2col(X,Y) ¬ color(X,red), color(Y,blue). color(X,red) color(X,blue) color(X,yellow) ¬

node(X).

¬ edge(X,Y), color(X,C), color(Y,C)

564

TEAM LinG

Rewriting and Efficient Computation of Bound Disjunctive Datalog Queries

Given a set of constraints PC , we denote with esv(PC) the set of Datalog rules obtained by replacing each constraint in PC having the form

¬ a1,...,ak, b1, .., bm, ← c1,..., ←cm

where a1,...,ak are base atoms and b1,...,bm are derived atoms, with the following set of rules:

bi ¬ b1,..,bi-1,b i+1,..,bK, a1,...,aK

i [1..m]

Moreover, given a disjunctive program P = (PR, PC), the extended standard version of P, denoted by esv(P) = esv(PR,PC) = esv(PR) esv(PC).

Example 5. The extended standard version of the program COLORING of Example 3, obtained by the rewriting of constraints and disjunctive rules and denoted by esv(COLORING ), is as follows:

r1: 2col(X,Y) ¬ color(X,red), color(Y,blue). s1: color(X,red) ¬ node(X).

s2: color(X,blue) ¬ node(X). s3: color(X,yellow) ¬ node(X).

s4: color(X,red) ¬ color(X,blue), node(X). s5: color(X,blue) ¬ color(X,red), node(X). s6: color(X,red) ¬ color(X,yellow), node(X). s7: color(X,yellow) ¬ color(X,red), node(X). s8: color(X,blue) ¬ color(X,yellow), node(X). s9: color(X,yellow) ¬ color(X,blue), node(X). c1: color(X,C) ¬ edge(X,Y), color(Y,C).

c2: color(Y,C) ¬ edge(X,Y), color(X,C).

where the rule r1 is derived from r, the rules s1-s9 are derived from the rule s, and the rules c1 and c2 are derived from the constraint c.

Moreover, we denote by ESV(P) the program derived from esv(P) by replacing each derived predicate symbol g with a new predicate symbol G.

Definition 1. Let P=( PR,PC) be a disjunctive Datalog program. The program Rew(P) is defined as RV(PR) PC ESV(P). Given a query Q = <g(t),P>, we denote with Rew(Q) the query <g(t),Rew(P)>.

Example 6. The set of restricted rules in RV(COLORING), derived from the program COLORING of Example 3, is as follows:

2col(X,Y) • 2COL(X,Y), color(X,red), color(Y,blue).

color(X,red) color(X,blue) color(X,yellow) • node(X), COLOR(X,red), COLOR(X,blue), COLOR(X,yellow).

where the predicates 2COL and COLOR are defined in ESV(COLORING) which is derived from the program 4 esv(COLORING), reported in Example 5, by replacing 2col

with 2COL and color with COLOR.

The complete rewriting of the program COLORING consists of the above rules plus the constraint:

edge(X,Y), color(X,C),color(Y,C).

and the rules in ESV(Coloring), presented in Example 5. The first interesting result is that (as for Datalog programs without constraints) the above rewriting

method does not affect the semantics of the query.

Proposition 1. Let P=(PR,PC) be a disjunctive Datalog program and Rew(P) be the rewritten version of P. Then, for every atom g(t) is <g(t), P> ≡ <g(t),Rew(P)>.

Thus, a viable way for reducing the number of models to be computed, by limiting the attentions to the ones that are really needed for answering the query, is to consider a program different w.r.t. ESV(P), which is able to make an effective and sound restriction.

Definition 2. Let Q=<g(t),P> with P =( PR,PC) be a disjunctive Datalog query, then the disjunctive magicset rewriting of P w.r.t. g(t), denoted by Disj_Magic(g(t),P), is equal to RV(PR) PC Coll(ESV(P), Magic(G(t),ESV(P))) Magic(G(t),ESV(P)).

EXPERIMENTAL RESULTS

In this section, we report some experimental results to give an idea of the improvements which can be obtained by means of our technique; the proposed algorithm has been included into the prototype presented in Greco (2003), and all the experiments have been carried out by means of the DLV system (Eiter et al., 1997b) on a PC with a Pentium 4, 1.7 GHz, and 512 Mbyte of RAM under the operating system Linux.

For the following queries, we have used graphs having the structure depicted in Figures 1(a) and 1(b) with base = height. Here, base denotes the number of nodes in the same layer, height the number of nodes in the same column, and output (input) grade the number of arcs starting from (ending at) each node. The number of nodes in the graph is base * height whereas the number of arcs is (base-1) * (height-1) * grade + (base-1) + (height-1) for the undirected graph G1 and base * (height-1) * grade for the directed graph G2. We also denote with G’1 a graph whose structure is derived from G1 by adding a dashed arc as reported in Figure 1(a).

565

TEAM LinG

Rewriting and Efficient Computation of Bound Disjunctive Datalog Queries

Figure 1 (a).

Figure 1 (b).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 2 (a).

Figure 2 (b).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 3 (a).

Figure 3 (b).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

566

TEAM LinG

Rewriting and Efficient Computation of Bound Disjunctive Datalog Queries

Figure 4(a).

Figure

4(b).

 

4

Example 7. 3-COLORING. We consider the query of Example 3 with input graphs consisting of two disconnected components with variable sizes and having the structure shown in Figure 2(a). We have assumed that the nodes appearing in the query goal belong to the same components; that is, the binding is propagated only on one component. In the following, we denote as first component the one on which the binding is propagated and, as second component, the one on which the binding is not propagated. The results are shown in Figure 2, where we have considered colorable graphs and, in Figure 3, where we have considered not colorable graphs. In Figure 2(a), we have considered graphs with two components with the same size, ranging from 3 * 3 to 20

*20 nodes. In Figure 2(b), we have considered graphs with two components having different sizes: the number of nodes in the first component ranges from 4 * 4 to 26

*26 while the number of nodes in the second component ranges from 4/2 * 4/2 to 26/2 * 26/2.

Example 8. Simple Path. The following example presents a query computing a simple path in a graph with start and end node fixed. A simple path is a path passing though the nodes once; a simple path is said to be hamiltonian if it passes through all nodes in the graph.

The first rule defines a partition of arcs into e and ne; the rules defining sp compute paths on the graph defined by e (selected edges); and the last two rules state that every simple path cannot contain two distinct nodes Y and Y1 (resp. X and X1) connected to the same node X (resp. Y).

We have used instances for the relation edge as depicted in Figure 2(b) with base = height and output grade = 2.

The results of the query are reported in Figure 4 where the x-axis shows the size of the graph. In more details,

Figure 3(a) reports the time to execute the query, whereas Figure 3(b) reports the number of disjunctive rules in the ground program. Also in this case, it results evident the great improvement provided by the proposed technique which ensures, for large graphs, more than one order of magnitude between the source and the optimized queries.

CONCLUSION

The main contribution of the paper consisted in extending previous techniques for query optimization to Datalog programs with both disjunctive heads and constraints.

The proposed approach consisted of two distinct phases: the rewriting of queries for propagating bindings from the query goal into the program and the use of specialized algorithms computing rewritten queries. We have shown that the technique is sound and complete and can be profitably used for search and optimization problems. Several experiments have confirmed the validity of our technique.

FUTURE TRENDS

A great interest has been devoted by the research community to the definition of efficient algorithms for both computing the semantics of programs and answering queries. This paper has shown the necessity for disjunctive queries of effective methodologies which systematically utilize the query to propagate bindings into the body of the rules to avoid the computation of all the models of the program. We are currently investigating an extension of the proposed technique to more flexible and powerful forms of constraints.

567

TEAM LinG

Rewriting and Efficient Computation of Bound Disjunctive Datalog Queries

REFERENCES

Abiteboul, S., Hull, R., & Vianu, V. (1995). Foundations of databases. Addison-Wesley.

Bancilhon, F., Mayer, D., Sagiv, Y., & Ullman, J.D. (1986). Magic sets and other strange ways to implement logic programs. Proceedings of the PODS Conference, 45(1-3) (pp. 1-16).

Beeri, C., & Ramakrishnan, R. (1991). On the power of magic. JLP, 10(1/2/3/4), 255-299.

Brass, S., & Dix, J. (1994). A general approach to bottom-up computation of disjunctive semantics. Proceedings of the ICLP ’94 W. on NELP (pp. 127-155).

Buccafurri, F., Leone, N., & Rullo, P. (2000). Enhancing disjunctive datalog by constraints. IEEE TKDE, 12(5), 845-860.

Eiter, T., Gottlob, G., & Mannila, H. (1997a). Disjunctive datalog. ACM TODS, 22(3), 364-418.

Eiter, T., Leone, N., Mateis, C., Pfeifer, G., & Scarcello, F. (1997b). A deductive system for non-monotonic reasoning. LPNMR, 363-374.

Fernandez, J.A., & Minker, J. (1995). Bottom-up compuation of perfect models for disjunctive theories. JLP, 25(1), 33-51.

Flesca, S., Greco, S., Trubitsyna, I., & Zumpano, E. (2003). On the semantics and expressive power of datalog-like languages for NP search and optimization problems (Tech. Rep.).

Gelfond, M., & Lifschitz, V. (1988). The stable model semantics for logic programming. ICLP, 1070-1080.

Gelfond, M., & Lifschitz, V. (1991). Classical negation in logic programs and disjunctive databases. NGC, 9(3/4), 365-385.

Greco, S. (1998). Non-determinism and weak constraints in datalog. NGC, 16(4), 373-396.

Greco, S. (2003). Binding propagation techniques for the optimization of bound disjunctive queries. IEEE TKDE, 15(2), 368-385.

Greco, G., Greco, S., Trubitsyna, I., & Zumpano, E. (2002). Query optimization of disjunctive databases with constraints through binding propagation. Proceedings of the LPAR Conference (pp. 216-230).

Greco, S., Saccà, D., & Zaniolo, C. (1995). The pushdown method to optimize chain logic programs. Proceedings of the ICALP Conference (pp. 523-534).

Leone, N., Rullo, P., & Scarcello, F. (1997). Disjunctive stable models: Unfounded sets, fixpoint semantics and computation. Inf. & Comp., 135(2), 69-112.

Lobo, J., Minker, J., & Rajasekar, A. (1992). Foundations of disjunctive logic programming. MIT Press.

Minker, J. (1982). On indefinite data bases and the closed world assumption. Proceedings of the 6th Conference on Automated Deduction (pp. 292-308).

Ramakrishnan, R., Sagiv, Y., Ullman, J.F., & Vardi, M.Y. (1993). Logical query optimization by proof-tree transformation. JCSS, 47(1), 222-248.

Ullman, J.K. (1989). Principles of database and knowl- edge-base systems (vol. 1). Computer Science Press.

KEY TERMS

Binding Propagation: Optimization technique based on the exploitation of binding propagation techniques which reduce the size of the data relevant to answer the query and, consequently, minimize both the complexity of computing a single model and the number of models to be considered.

Database: A database (instance) is a set of finite relations over a fixed database schema. Each relation consists of a set of ground facts, that is, variables free facts.

Disjunctive Datalog Program: A disjunctive Datalog program is a set of rules r of the form:

A1 … Ak • B1, ..., Bm, ¬Bm+1, …,¬Bn,

where k+m+n>0, A1,…, Ak, B1,…, Bn are atoms of the form p(t1,..., th), p is a predicate symbol of arity h, and the terms t1,..., th are constants or variables. The disjunction A1 … Ak is called head of r and is denoted by

Head(r) while the conjunction B1, ..., Bm, ¬Bm+1, …,¬Bn is called body and is denoted by Body(r). If k=1, then r is

normal (i.e. -free); if n=0, then r is positive (i.e. ¬- free); if both m=1 and n=0, then r is normal and positive; if k=n=0 then r is a fact, whereas if m=0 then r is a constraint or denial rule, that is, a rule which is satisfied only if Body(r) is false.

Logic Queries: A disjunctive datalog query over a database defines a mapping from the database to a finite (possibly empty) set of finite (possibly empty) relations

568

TEAM LinG

Rewriting and Efficient Computation of Bound Disjunctive Datalog Queries

for the goal. A query is a pair <G,P> where G is an atom, called goal, and P is a program. The application of a query Q to a database D is denoted by Q(D).

Magic Set Technique: Binding propagation technique based on the rewriting of the source query, with respect to the query goal, into an equivalent query which simulates top-down evaluation by bottom-up query computation engines so that irrelevant facts are not considered.

Query Answer: The result of a query Q = <G,P> on an input database D is defined in terms of the stable models of P D by taking either the union (possible inference) or the intersection (certain inference) of all models. Thus, given a program P and a database D, a ground atom G is true under possible (brave) semantics if there exists a stable model M for P D such that G M. Analogously, G is true under certain (cautious) semantics if G is true in every stable model for P D.

Query Equivalence: Two queries Q1 = <G1,P1> and Q2

= <G2,P2> are said to be equivalent under semantics s (Q1 4 s Q2) if for every database D (on a fixed schema) Anss(Q1,D)

= Anss(Q2,D). Two programs P1 and P2 are equivalent under a given semantics s: P1 s P2 if for every atom g <g, P1> s <g, P2>. Finally, if Q1 p Q2 and Q1 c Q2 (the two queries or programs are equivalent under both brave and cautious semantics), we simply write Q1 Q2.

Stable Models: An interpretation M is a stable model for a disjunctive Datalog program P if and only if M is a minimal program for the program PM denoting the ground positive program derived from ground(P) by (1) removing all rules that contain a negative literal ¬ a in the body and a M, and (2) removing all negative literals from the remaining rules.

569

TEAM LinG

Соседние файлы в предмете Электротехника