Abstract
The query equivalence problem has been studied extensively for set-semantics and, more recently, for bag and bag-set semantics. However, SQL queries often combine set, bag and bag-set semantics. For example, an SQL query that returns a multiset of elements may call a subquery or view that returns a set of elements. Queries may access both relations that do not contain duplicates, as well as relations with duplicates. As another example, in SQL one can compute a multiset-union of queries, each of which returns a set of answers. This paper presents combined semantics, which formally models query evaluation combining set, bag and bag-set semantics. The equivalence problem for queries evaluated under combined semantics is studied. A sufficient condition for equivalence is presented. For several important common classes of queries necessary and sufficient conditions for equivalence are presented.
Similar content being viewed by others
References
Aho A.V., Sagiv Y., Ullman J.D.: Efficient optimization of a class of relational expressions. ACM Trans. Database Syst. 4(4), 435–454 (1979)
Calvanese, D., Giacomo, G.D., Vardi, M.Y.: Decidable containment of recursive queries. In: Calvanese, D., et al. (eds.) In: Proceedings of the 9th International Conference on Database Theory, Siena, Italy, January 8–10, 2003, pp. 327–342
Chandra, A.K., Merlin, P.M.: Optimal implementation of conjunctive queries in relational data bases. In: STOC, pp. 77–90. ACM Press, New York (1977)
Chaudhuri, S.: An overview of query optimization in relational systems. In: PODS, pp. 34–43. ACM Press, New York (1998)
Chaudhuri, S., Vardi, M.Y.: Optimization of real conjunctive queries. In: PODS, pp. 59–70. ACM Press, New York (1993)
Chekuri C., Rajaraman A.: Conjunctive query containment revisited. Theor. Comput. Sci. 239(2), 211–229 (2000)
Cohen, S.: Equivalence of queries combining set and bag-set semantics. In: Vansummeren, S. (ed.) Proceedings of the Twenty- Fifth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, June 26–28, 2006, Chicago, Illinois, Maryland, USA, pp. 70–79
Cohen, S., Nutt, W., Serebrenik, A.: Rewriting aggregate queries using views. In: PODS, pp. 155–166. ACM Press, New York (1999)
Cohen, S., Nutt, W., Sagiv, Y.: Containment of Aggregate Queries. In: Calvanese, D., et al. (eds.) Proceedings of the 9th International Conference on Database Theory, Siena, Italy, January 8--10, 2003, pp. 111–125
Cohen S., Sagiv Y., Nutt W.: Equivalences among aggregate queries with negation. ACM Trans. Comput. Log. 6(2), 328–360 (2005)
Cohen, S., Nutt, W., Sagiv, Y.: Deciding equivalences among conjunctive aggregate queries. J. ACM 54(2), (2007)
Dayal, U.: Of nests and trees: a unified approach to processing queries that contain nested subqueries, aggregates, and quantifiers. In: Stocker, P.M., Kent, W., Hammersley, P. (eds.) VLDB, pp. 197–208. Morgan Kaufmann, San Francisco (1987)
Halevy A.Y.: Answering queries using views: a survey. VLDB J. 10(4), 270–294 (2001)
Halevy A.Y., Mumick I.S., Sagiv Y., Shmueli O.: Static analysis in datalog extensions. J. ACM 48(5), 971–1012 (2001)
Ioannidis Y.E., Ramakrishnan R.: Containment of conjunctive queries: beyond relations as sets. ACM Trans. Database Syst. 20(3), 288–324 (1995)
Jayram, T.S., Kolaitis, P.G., Vee, E.: The containment problem for real conjunctive queries with inequalities. In: Vansummeren, S. (ed.) Proceedings of the Twenty-Fifth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, June 26–28, 2006, Chicago, Illinois, Maryland, USA, pp. 80–89
Johnson D.S., Klug A.C.: Optimizing conjunctive queries that contain untyped variables. SIAM J. Comput. 12(4), 616–640 (1983)
Khizder V.L., Toman D., Weddell G.E.: Reasoning about duplicate elimination with description logic. In: Lloyd, J.W., Dahl, V., Furbach, U., Kerber, M., Lau, K.-K., Palamidessi, C., Pereira, L.M., Sagiv, Y., Stuckey, P.J. (eds.) Computational Logic. Lecture Notes in Computer Science, vol. 1861, pp. 1017–1032. Springer, Berlin (2000)
Kim W.: On optimizing an SQL-like nested query. ACM Trans. Database Syst. 7(3), 443–469 (1982)
Klug A.C.: On conjunctive queries containing inequalities. J. ACM 35(1), 146–160 (1988)
Levy, A.C., Sagiv, Y.: Semantic query optimization in datalog programs. In: PODS, pp. 163–173. ACM Press, New York (1995)
Muralikrishna M.: Improved unnesting algorithms for join aggregate sql queries. In: Yuan, L.-Y. (ed) VLDB, pp. 91–102. Morgan Kaufmann, San Francisco (1992)
Paulley, G.N., Larson, P.-Å.: Exploiting uniqueness in query optimization. In: ICDE, pp. 68–79. IEEE Computer Society, USA (1994)
Pottinger R., Halevy A.Y.: Minicon: a scalable algorithm for answering queries using views. VLDB J. 10(2–3), 182–198 (2001)
Sagiv Y., Saraiya Y.P.: Minimizing restricted-fanout queries. Discrete Appl. Math. 40(2), 245–264 (1992)
Sagiv Y., Yannakakis M.: Equivalences among relational expressions with the union and difference operators. J. ACM 27(4), 633–655 (1980)
Ullman J.D.: Principles of Database and Knowledge-Base Systems, vol. I. Computer Science Press, New York (1988)
Ullman J.D.: Principles of Database and Knowledge-Base Systems, vol. II. Computer Science Press, New York (1989)
van der Meyden R.: The complexity of querying indefinite data about linearly ordered domains. J. Comput. Syst. Sci. 54(1), 113–135 (1997)
Author information
Authors and Affiliations
Corresponding author
Additional information
An early version of this article appeared in [7]. This paper extends [7] to include bag semantics, in addition to set and bag-set semantics. This work was partially supported by the Israel Science Foundation (Grant 1032/05).
Rights and permissions
About this article
Cite this article
Cohen, S. Equivalence of queries that are sensitive to multiplicities. The VLDB Journal 18, 765–785 (2009). https://doi.org/10.1007/s00778-008-0122-1
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00778-008-0122-1