Presentation is loading. Please wait.

Presentation is loading. Please wait.

Local-as-View Mediators

Similar presentations


Presentation on theme: "Local-as-View Mediators"— Presentation transcript:

1 Local-as-View Mediators

2 In a LAV mediator, we define global predicates at the mediator.
We define, for each source, one or more expressions involving the global predicates that describe the tuples that the source is able to produce. Queries are answered at the mediator by discovering all possible ways to construct the query using the views provided by the source.

3 Motivation for LAV Mediators
Sometimes there can be situation where the relationship between what we want to provide to users of the mediator and what the sources provide is more subtle. For example, consider the predicate Par(c, p) meaning that p is a parent of c which represents the set of all child parent facts that could ever exist. The sources will provide information about whatever child-parent facts they know.

4 There can be sources which may provide child-grandparent facts but not child- parent facts at all.
This source can never be used to answer the child-parent query under GAV mediators. LAV mediators allow us to say that a certain source provides grand parent facts. They let us discover how and when to use that source in a given query.

5 Terminology The queries at the mediator and the queries that describe the source will be single Datalog rules. A query that is a single Datalog rule is often called a conjunctive query. A LAV mediator has a set of global predicates, which are used as the subgoals of mediator queries. There are conjunctive queries that define views.

6 Their heads each have a unique view predicate that is the name of a view.
Each view definition has a body consisting of global predicates and is associated with a particular source, from which that view can be constructed. We assume that each view can be constructed with an all-free adornment.

7 Example.. Suppose there is one global predicate Par(c, p) meaning that p is a parent of c. One source produces some of the possible parent facts. Its view is defined by the conjunctive query- V1(c, p)  Par(c, p) Another source produces some grand parents facts. Then its conjunctive query will be – V2(c, g)  Par(c, p) AND Par(p, g)

8 The query at the mediator will ask for great-grand parent facts that can be obtained from the sources. The mediator query is – Q(w, z)  Par(w, x) AND Par(x, y) AND Par(y, z) One solution can be using the parent predicate(V1) directly three times. Q(w, z)  V1(w, x) AND V1 (x, y) AND V1(y, z)

9 Another solution can be to use V1(parent facts) to make a step of one generation and V2(grandparent facts) to make a step of two generations. Q(w, z)  V1(w, x) AND V2(x, z) Or Q(w, z)  V2(w, y) AND V1(y, z)

10 Expanding Solutions Consider a query Q, a solution S that has a body whose subgoals are views and each view V is defined by a conjunctive query with that view as the head. We can substitute the body of V’s conjunctive query for a subgoal in S that uses the predicate Vas long as we are careful not to confuse variable names from one body with those of another.

11 Expansion Algorithm A solution S has a subgoal V(a1, a2,…an) where ai’s can be any variables or constants. The view V can be of the form V(b1, b2,….bn)  B Where B represents the entire body. We can replace V(a1, a2, … an) in solution S by a version of body B that has all the subgoals of B with variables possibly altered.

12 The rules for altering the variables of B are:
First identify the local variables B, variables that appear in the body but not in the head. If there are any local variables of B that appear in B or in S, replace each one by a distinct new variable that appears nowhere in the rule for V or in S. In the body, replace each bi by ai for i = 1,2…n.

13 In the child-parent example, we had view definitions,
V1(c, p)  Par(c, p) V2(c, g)  Par(c, p) AND Par(p, g) One of the proposed solutions S is Q(w, z)  V1(w, x) AND V2(x, z) The first subgoal with predicate V1 in the solution can be expanded as Par(w, x) as there are no local variables.

14 The V2 subgoal has a local variable p which doesn’t appear in S nor it has been used as a local variable in another substitution. So p can be left as it is. Only x and z are to be substituted for variables c and g. The Solution S now will be Q(w, z)  Par(w, x) AND Par(x, p) AND Par(p,z)

15 Containment of Conjunctive Queries
A containment mapping from Q to E is a function т from the variables of Q to the variables and constants of E, such that: If x is the ith argument of the head of Q, then т(x) is the ith argument of the head of E. Add to т the rule that т(c)=c for any constant c. If P(x1,x2,… xn) is a subgoal of Q, then P(т(x1), т(x2),… т(xn)) is a subgoal of E.

16 Example.. Consider two Conjunctive queries:
Q1: H(x, y)  A(x, z) and B(z, y) Q2: H(a, b)  A(a, c) AND B(d, b) AND A(a, d) We can say there is a containment mapping from Q1 to Q2. When we apply the substitution, Т(x) = a, Т(y) = b, Т(z) = d, the head of Q1 becomes H(a, b) which is the head of Q2.

17 The first subgoal of Q1 becomes A(a, d) which is the third subgoal of Q2.
The second subgoal of Q1 becomes the second subgoal of Q2. There is also a containment mapping from Q2 to Q1 so the two conjunctive queries are equivalent.

18 Why the Containment-Mapping Test Works
Suppose there is a containment mapping т from Q1 to Q2. When Q2 is applied to the database, we look for substitutions σ for all the variables of Q2. The substitution for the head becomes a tuple t that is returned by Q2. If we compose т and then σ, we have a mapping from the variables of Q1 to tuples of the database that produces the same tuple t for the head of Q1.

19 Finding Solutions to a Mediator Query
LMSS Theorem states that If a query Q has n subgoals, then any answer produced by any solution is also produced by a solution that has at most n subgoals.

20 Recall the query Q1: Q(w, z) Par(w, x) AND Par(x, y) AND Par(y, z) This query has three subgoals, so we don’t have to look at solutions with more than three subgoals.

21 Why the LMSS Theorem Holds
Suppose we have a query Q with n subgoals and there is a solution S with more than n subgoals. The expansion E of S must be contained in Query Q, which means that there is a containment mapping from Q to E. We remove from S all subgoals whose expansion was not the target of one of Q’s subgoals under the containment mapping.

22 We would have a new conjunctive query S’ with at most n subgoals.
If E’ is the expansion of S’ then, E’ is a subset of Q. S is a subset of S’ as there is an identity mapping. Thus S need not be among the solutions to query Q.

23


Download ppt "Local-as-View Mediators"

Similar presentations


Ads by Google