Query rewriting is one of the oldest problems in data management. Earlier studies focused on improving performance of query evaluation , since using materialized views can save the execution cost of a query. In 1995, Levy et al.  formally studied the problem and developed complexity results. The problem became increasingly more important due to new applications such as data integration, in which views are used widely to describe the semantics of the data at different sources and queries posed on the global schema. Many algorithms have been developed, including the bucket algorithm  and the inverse-rules algorithm [15, 7]. See  for an excellent survey.