local-as-view mediators priya gangaraju(class id:203)
Post on 20-Dec-2015
217 views
TRANSCRIPT
Local-as-View Mediators
Priya Gangaraju(Class Id:203)
Local-as-View Mediators.• Global predicates defined are not views of the
source data.• Global predicates describe the tuples that the
source is able to produce.• For each source:– expressions are defined– expressions involve the global predicates
• Queries are answered at the mediator by discovering all possible ways to construct the query using the views provided by the source.
Motivation for LAV Mediators
• Sometimes the the relationship between what the mediator should provide 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.
Motivation(contd..)
• 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 to say that a certain source provides grand parent facts.
• They help discover how and when to use that source in a given query.
Terminology for LAV Mediation.
• single Datalog rules: The queries at the mediator and the queries that describe the source
• Conjunctive query : A query that is a single Datalog rule. They can also define views.
• Global predicates: they are used as the sub-goals of mediator queries.
Contd..
• Head: Each head have a unique view• Predicate : The name of a view.• Body: Consist of global predicates and is
associated with a particular source.• It is assumed that each view can be
constructed with an all-free adornment.
Example..
• Consider global predicate Par(c, p) meaning that p is a parent of c.
• One source produces 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)
Example contd..
• 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)
Example contd..
• Another solution can be to use V1(parent facts) and V2(grandparent facts).
Q(w, z) V1(w, x) AND V2(x, z)
Or Q(w, z) V2(w, y) AND V1(y, z)
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.
• The body of V’s conjunctive query can be substituted for a subgoal in S that uses the predicate V to have a body consisting of only global predicates.
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.• V(a1, a2, … an) can be replaced in solution S by
a version of body B that has all the subgoals of B with variables possibly altered.
Expansion Algorithm contd..
The rules for altering the variables of B are:1. First identify the local variables B, variables
that appear in the body but not in the head.2. 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.
3. In the body B, replace each bi by ai for i = 1,2…n.
Example.
• Consider the 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.
Example Contd.
• 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)
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:
1. If x is the ith argument of the head of Q, then т(x) is the ith argument of the head of E.
2. 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.
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)
• 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.
So,there is a containment mapping from Q1 to Q2.
Example contd..
• 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.
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.
Finding Solutions to a Mediator Query
• There can be infinite number of solutions built from the views using any number of subgoals and variables.
• LMSS Theorem can limit the search which states thato 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.
• If the conjunctive query that defines a view V has in its body a predicate P that doesn’t appear in the body of the mediator query, then we need not consider any solution that uses V.
Example.
• Recall the queryQ1: 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.
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.
Contd..
• 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.