**3. Query processing techniques**

Work on query processing over semantic cache is mainly classified in query intersection (Lee et al., 1999), query trimming (Keller A.M. and Basu J., 1996),(Ren, Q et al., 2003), answering queries using views (Levy A.Y et al., 1996), (Duschka O.M. and Genesereth M.R.

Semantic Cache Reasoners 85

domain in predicate condition. According to Lee (1999, pp.28-36) two queries are disjoint if either intersection of their projected attributes is empty or there is no combined condition

QU ∩ QC = <QUA ∩ QCA, QUP ∩ QCP, R> (i)

QC1 = <{Ename,Department}, {-,-,-,{50,…,100},-}, Emp> (iii) QU = <{Ename,Department}, {-,-,-,{55,….,100},-}, Emp> (iv)

The concept of query trimming was introduced by (Keller A.M. and Basu J., 1996) and formally given by Ren (2003, pp.192-210). Ren (2003, pp.192-210) gave a comprehensive algorithm for query processing. In the start of the algorithms it is checked if the user query attributes are subset of cached semantics attributes, then perform query trimming based upon the implication or satisfiability of predicates. If the user query attributes is not a subset of cached semantics attributes, then there may be some common attributes. In this case, if query predicate implies cache predicates or there are common predicates between the query and cache semantics, then form the probe and remainder query as per the logic given by the algorithm. In other words the logic is based on checking implication and satisfiability of a user and cached query predicates (based upon the already published material, as explained in the next section) and finding common part between the user and cached query attributes. Much work has been contributed towards finding implication and satisfiablity between a user and cached query predicates (Guo S et al., 1996), (Härder T. and Bühmann A., 2008). Simplified concept of implication and satisfiability is, let us have a user query predicate QUP

QUP QCP, i.e. User predicate implies segment predicates, implying that the whole

(QUP QCP is unsatisfiable), implying that there is no common part between QUP and

Remainder queries were trimmed again after comparing with other semantic cache segments with the same algorithm. It continues until it is decided that the cache does not further contribute to the query answering. This approach forms an iterative behavior, which was handled by a proposed query plan tree structure. This plan tree expresses the

Query trimming techniques have some short comings, such as time and space efficiency, and complexity of the trimming process (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010). When query is trimmed into probe (QUP QCP) and remainder (QUP QCP) part, the negation of the cached query predicate in remainder part make it much more expanded term if it contains disjunctions. This expansion created by negation of a term

(QUP QCP is satisfiable), implying that part of QUP answer is contained in QCP.

πQUA ∩ QCA , σQUP ∩ QCP (ii)

and semantic segment predicate QCP, then there are three scenarios:

between user and cached query predicates.

Fig. 4. Query Intersection (Lee et al., 1999).

answer of QUP is contained in QCP.

relationship of cache items and query subparts.

was shown with example (Makki K. S and Andrei S, 2009).

**3.2 Query trimming** 

QCP.

Fig. 2. Employee relation.

*QC1 ← π Ename, Department σ Age ≥<sup>50</sup> (Emp); QC2 ← π Age, Department (Emp); QC3 ← π Ename, Department σ Salary>10k (Emp); QC4 ← π Age, Salary σ Salary ≤ 30k (Emp); QC5 ← π Ename, Salary, Exp (Emp); QC6 ← π Age σ Age < 70 (Emp); QC7 ← π Age,Salary,Exp σ Salary≥1K Salary<=40K*

Fig. 3. Cached Queries.

1997), (Pottinger R. and Levy A. 2000), semantic cache for web queries (Chidlovskii B and Borghoff U. M., 2000), (Qiong L and Jaffrey F. N., 2001), xml based semantic cache (Mandhani B. and Suciu D., 2005), (Sanaullah, M., 2008) and description logic based subsumption analysis in semantic cache (Baader et al., 1991a) (Hollunder et al., 1990) techniques.

#### **3.1 Query intersection**

Query processing for the five scenarios similar to Figure 1 and one additional scenario which shows cache as a subset of incoming queries (reverse of case 1 of Figure 1) was presented by Lee (1999, pp.28-36). Against each scenario probe and remainder query were computed based on cache and query intersection or difference. Intersection and difference of cache semantics and a posed query were mentioned at a very abstract level.

Definition of intersection (Lee et al., 1999) between semantics of cache region QC and a user query QU on relation R is shown in statement (i) of Figure 4. This intersection consists of two parts. One is the common projected attributes while the other is combined condition of a user and cached query predicates (Shown in statement (ii) of Figure 4). A query or cache semantics are represented as a triple < πQ, σQ, operandQ >. πQ is the projected attributes, operandQ is the base relation. Where any predicate condition (σQ) is represented as a value domain list {dQ,1, dQ,2, ..., dQ,n} and a condition is satisfiable if none of the value domain is null. We elaborate this concept with an example.

Consider the database schema information provided in example 1 above. A user query QU over cached query QC1 of Figure 3 are represented as triple < πQ, σQ, operandQ > in statement (iv) and (iii) of Figure 4 respectively. The query QU is statisfiable (or completely answerable) from QC1 because intersection of projected attributes is not empty and there is no null value 84 Semantics – Advances in Theories and Mathematical Models

ment

Salary Exp

Age

Emp

*QC1 ← π Ename, Department σ Age ≥<sup>50</sup> (Emp);* 

*QC3 ← π Ename, Department σ Salary>10k (Emp); QC4 ← π Age, Salary σ Salary ≤ 30k (Emp);* 

*QC7 ← π Age,Salary,Exp σ Salary≥1K Salary<=40K*

1997), (Pottinger R. and Levy A. 2000), semantic cache for web queries (Chidlovskii B and Borghoff U. M., 2000), (Qiong L and Jaffrey F. N., 2001), xml based semantic cache (Mandhani B. and Suciu D., 2005), (Sanaullah, M., 2008) and description logic based subsumption analysis in semantic cache (Baader et al., 1991a) (Hollunder et al., 1990)

Query processing for the five scenarios similar to Figure 1 and one additional scenario which shows cache as a subset of incoming queries (reverse of case 1 of Figure 1) was presented by Lee (1999, pp.28-36). Against each scenario probe and remainder query were computed based on cache and query intersection or difference. Intersection and difference of

Definition of intersection (Lee et al., 1999) between semantics of cache region QC and a user query QU on relation R is shown in statement (i) of Figure 4. This intersection consists of two parts. One is the common projected attributes while the other is combined condition of a user and cached query predicates (Shown in statement (ii) of Figure 4). A query or cache semantics are represented as a triple < πQ, σQ, operandQ >. πQ is the projected attributes, operandQ is the base relation. Where any predicate condition (σQ) is represented as a value domain list {dQ,1, dQ,2, ..., dQ,n} and a condition is satisfiable if none of the value domain is

Consider the database schema information provided in example 1 above. A user query QU over cached query QC1 of Figure 3 are represented as triple < πQ, σQ, operandQ > in statement (iv) and (iii) of Figure 4 respectively. The query QU is statisfiable (or completely answerable) from QC1 because intersection of projected attributes is not empty and there is no null value

cache semantics and a posed query were mentioned at a very abstract level.

null. We elaborate this concept with an example.

*QC2 ← π Age, Department (Emp);* 

*QC5 ← π Ename, Salary, Exp (Emp); QC6 ← π Age σ Age < 70 (Emp);* 

Fig. 2. Employee relation.

Fig. 3. Cached Queries.

**3.1 Query intersection** 

techniques.

Empid Ename Depart

domain in predicate condition. According to Lee (1999, pp.28-36) two queries are disjoint if either intersection of their projected attributes is empty or there is no combined condition between user and cached query predicates.

$$\begin{array}{l} \mathrm{Q}\_{\mathrm{U}} \cap \mathrm{Q}\_{\mathrm{C}} = \mathrm{<} \mathrm{Q}\_{\mathrm{UA}} \cap \mathrm{Q}\_{\mathrm{CA}}, \mathrm{Q}\_{\mathrm{UP}} \cap \mathrm{Q}\_{\mathrm{CP}}, \mathrm{R} > \mathrm{} & \mathrm{(i)}\\\pi\_{\mathrm{Q}|\mathrm{A}\cap\mathrm{Q}<\mathrm{A}}, \,\mathsf{G}\_{\mathrm{Q}|\mathrm{IP}\cap\mathrm{Q}<\mathrm{P}} \mathrm{P}\_{\mathrm{C}} & \mathrm{(ii)}\\\mathrm{Q}\_{\mathrm{C}1} = \mathrm{<} \{\mathrm{Ename}, \mathrm{Department}\}, \,\{\cdot, -, , \,\{50, \dots, 100\}, \cdot\}, \,\mathrm{Emp}\,\mathrm{(iii)}\\\mathrm{Q}\_{\mathrm{U}} = \mathrm{<} \{\mathrm{Ename}, \mathrm{Department}\}, \,\{\cdot, -, , \,\{55, \dots, 100\}, \cdot\}, \,\mathrm{Emp}\,\mathrm{(iv)} \end{array}$$

Fig. 4. Query Intersection (Lee et al., 1999).

#### **3.2 Query trimming**

The concept of query trimming was introduced by (Keller A.M. and Basu J., 1996) and formally given by Ren (2003, pp.192-210). Ren (2003, pp.192-210) gave a comprehensive algorithm for query processing. In the start of the algorithms it is checked if the user query attributes are subset of cached semantics attributes, then perform query trimming based upon the implication or satisfiability of predicates. If the user query attributes is not a subset of cached semantics attributes, then there may be some common attributes. In this case, if query predicate implies cache predicates or there are common predicates between the query and cache semantics, then form the probe and remainder query as per the logic given by the algorithm. In other words the logic is based on checking implication and satisfiability of a user and cached query predicates (based upon the already published material, as explained in the next section) and finding common part between the user and cached query attributes.

Much work has been contributed towards finding implication and satisfiablity between a user and cached query predicates (Guo S et al., 1996), (Härder T. and Bühmann A., 2008). Simplified concept of implication and satisfiability is, let us have a user query predicate QUP and semantic segment predicate QCP, then there are three scenarios:


Remainder queries were trimmed again after comparing with other semantic cache segments with the same algorithm. It continues until it is decided that the cache does not further contribute to the query answering. This approach forms an iterative behavior, which was handled by a proposed query plan tree structure. This plan tree expresses the relationship of cache items and query subparts.

Query trimming techniques have some short comings, such as time and space efficiency, and complexity of the trimming process (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010). When query is trimmed into probe (QUP QCP) and remainder (QUP QCP) part, the negation of the cached query predicate in remainder part make it much more expanded term if it contains disjunctions. This expansion created by negation of a term was shown with example (Makki K. S and Andrei S, 2009).

Semantic Cache Reasoners 87

(2) (*X < Y +C*) (*X ≤ Y + C*) (*X ≠ Y + C*) (3) (*X > Y + C*) (*Y ≤ X – C*) (*X ≠ Y + C*) (4) (*X = Y + C*) (*Y ≤ X – C*) (*X ≤ Y + C*)

Satisfiability of a conjunctive query *Q* is computed by constructing a connected weighteddirected graph GQ=(VQ,EQ) of *Q* after above transformation. Where VQ are the nodes representing predicate attributes of an inequality and EQ represent an edge between two nodes. An inequality of the form X op Y + C has X and Y nodes and an edge between them with C weight. The inequality X op C is transformed to X op V0 + C by introducing a

According to GSW (Guo et al., 1996) algorithm, for any query *Q* if a negative-weighted cycle (a cycle whose sum of edges weight is negative) found in GQ then *Q* is unsatisfiable. Otherwise *Q* is satisfiable. Testing satisfiability among user query *QU* and cached segment *QS* require us to construct a graph (GQu Qs) of (*QU QS*) and check GQu Qs for any negative weighted cycle. Negative weighted cycle is found through Floyd-Warshall algorithm (R.W. Floyd, 1962). Complexity of Floyd-Warshall algorithm is O(|V|3), so

An algorithm with O(|S|3 + K) complexity for solving the implication problem between two conjunctive inequalities *S* and *T* was presented by Ullman (J.D. Ullman, 1989) and Sun (Sun et al., 1989). Conjunctive queries of the form X op Y were studied by (A.Klug, 1988) and (Sun et al., 1989). Implication between conjunctive queries of the form X op Y +C was addressed by GSW algorithm (Guo et al., 1996) with complexity O(|*QU*|2 + |*QC*|). GSW Implication (Guo et al., 1996) requires that *QU* is satisfiable. At first the implication algorithm constructs the closure of *QU* i.e., a universal set that contains all those inequalities that are implied by

 [(V0 ≤ Salary -1), (Salary ≤ V0 +40), (V0 ≤ Salary -20), (V0 ≤ Age -30), (Age ≤ V0 +80), (Exp ≤ V0 +40)]

over cached segment *QC7* of Example 1. The directed weighted graph G*QU1 QC7* of *QU1 QC7* is shown in Figure 5(a). *QU1* is satisfiable with respect to *QC7*, as there is no negative

Age,Salary,Exp

Salary≥20K Age≥<sup>30</sup> Age≤<sup>80</sup> Exp≤<sup>40</sup>

(1) (*X ≥ Y+C*) (*Y ≤ X – C*)

(5) (*X < C*) (*X ≤ C*) (*X ≠ C*) (6) (*X > C*) (*X ≥ C*) (*X ≠ C*) (7) (*X = C*) (*X ≤ C*) (*X ≥ C*)

dummy node V0.

finding satisfiability become O(|*QU QS* |3).

*QU*. Then, *QU QS* if *QS* is a subset of the *QU* closure.

Fig. 5. (a) [*QU1 QS*] and G*QU1 QS* (b) Shortest Path Table

**Example 2:** Let us have a user query *QU1* =

weighted cycle in G*QU QC7.*

A relational query can be visualized as a rectangle with boundaries set by query predicate values. So according to (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010) semantic cache query processing based on query trimming is problem of finding intersection between two finite rectangles. Six cases that are extended form of Figure 1.1 are given in (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010) to show relationship between rectangles of user and cached queries. These rectangular representations do not depict implicit knowledge present in the semantics of user and cached queries. An technique named Flattening Bi-dimensional Interval Constraints (FBIC) was proposed (Makki K. S and Andrei S, 2009). Based on FBIC an algorithm for handling disjunctive and conjunctive queries was given by Makki (Makki K. S and Rockey M., 2010). The algorithm works for only single disjunctive case, where conjunctive cases are same as provided by (Makki K. S and Andrei S, 2009).

Finding intersection between rectangles of user and cached queries was done by comparing Bounds (Lower or Upper) of both rectangles. But computing comparable bounds were not given (Makki K. S and Andrei S, 2009), (Makki K. S and Rockey M., 2010).
