The Challenge of Optional Matching in SPARQL

  • Shqiponja Ahmetaj
  • Wolfgang Fischl
  • Markus Kröll
  • Reinhard PichlerEmail author
  • Mantas Šimkus
  • Sebastian Skritek
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9616)


Conjunctive queries are arguably the most widely used querying mechanism in practice and the most intensively studied one in database theory. Answering a conjunctive query (CQ) comes down to matching all atoms of the CQ simultaneously into the database. As a consequence, a CQ fails to provide any answer if the pattern described by the query does not exactly match the data. CQs might thus be too restrictive as a querying mechanism for data on the web, which is considered as inherently incomplete. The semantic web query language SPARQL therefore contains the OPTIONAL operator as a crucial feature. It allows the user to formulate queries which try to match parts of the query over the data if available, but do not destroy answers of the remaining query otherwise. In this article, we have a closer look at this optional matching feature of SPARQL. More specifically, we will survey several results which have recently been obtained for an interesting fragment of SPARQL – the so-called well-designed SPARQL graph patterns.


Optical Matching SPARQL Graph Pattern Conjunctive Queries (CQs) Triple Patterns Entailment Regime 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.



This work was supported by the Vienna Science and Technology Fund (WWTF), project ICT12-15 and by the Austrian Science Fund (FWF): P25207-N23 and W1255-N23.


  1. 1.
    Abiteboul, S., Hull, R., Vianu, V.: Foundations of Databases. Addison Wesley, Boston (1995). zbMATHGoogle Scholar
  2. 2.
    Ahmetaj, S., Fischl, W., Pichler, R., Simkus, M., Skritek, S.: Towards reconciling SPARQL and certain answers. In: Proceedings of the WWW 2015, pp. 23–33. ACM (2015)Google Scholar
  3. 3.
    Angles, R., Gutierrez, C.: The expressive power of SPARQL. In: Sheth, A.P., Staab, S., Dean, M., Paolucci, M., Maynard, D., Finin, T., Thirunarayan, K. (eds.) ISWC 2008. LNCS, vol. 5318, pp. 114–129. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  4. 4.
    Aranda, C.B., Arenas, M., Corcho, Ó., Polleres, A.: Federating queries in SPARQL 1.1: syntax, semantics and evaluation. J. Web Sem. 18(1), 1–17 (2013)CrossRefGoogle Scholar
  5. 5.
    Arenas, M., Pérez, J.: Querying semantic web data with SPARQL. In: Proceedings of the PODS 2011, pp. 305–316. ACM (2011)Google Scholar
  6. 6.
    Baader, F., Calvanese, D., McGuinness, D.L., Nardi, D., Patel-Schneider, P.F. (eds.): The Description Logic Handbook: Theory, Implementation, and Applications. Cambridge University Press, Cambridge (2003)zbMATHGoogle Scholar
  7. 7.
    Barceló, P., Libkin, L., Romero, M.: Efficient approximations of conjunctive queries. SIAM J. Comput. 43(3), 1085–1130 (2014)MathSciNetCrossRefzbMATHGoogle Scholar
  8. 8.
    Barceló, P., Pichler, R., Skritek, S.: Efficient evaluation and approximation of well-designed pattern trees. In: Proceedings of the PODS 2015, pp. 131–144. ACM (2015)Google Scholar
  9. 9.
    Calì, A., Gottlob, G., Kifer, M.: Taming the infinite chase: Query answering under expressive relational constraints. In: Proceedings of the KR 2008, pp. 70–80. AAAI Press (2008)Google Scholar
  10. 10.
    Calvanese, D., De Giacomo, G., Lembo, D., Lenzerini, M., Rosati, R.: Tractable reasoning and efficient query answering in description logics: The DL-Lite family. J. Autom. Reason. 39(3), 385–429 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  11. 11.
    Chandra, A.K., Merlin, P.M.: Optimal implementation of conjunctive queries in relational data bases. In: Proceedings of the STOC 1977, pp. 77–90. ACM (1977)Google Scholar
  12. 12.
    Chekuri, C., Rajaraman, A.: Conjunctive query containment revisited. Theor. Comput. Sci. 239(2), 211–229 (2000)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Cyganiak, R., Wood, D., Lanthaler, M.: RDF 1.1 concepts and abstract syntax. W3C Recommendation, W3C (2014).
  14. 14.
    Glimm, B., Ogbuji, C.: SPARQL 1.1 Entailment Regimes. W3C Recommendation, W3C, March 2013.
  15. 15.
    Gottlob, G., Leone, N., Scarcello, F.: Hypertree decompositions and tractable queries. J. Comput. Syst. Sci. 64(3), 579–627 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Greco, S., Spezzano, F., Trubitsyna, I.: Checking chase termination: Cyclicity analysis and rewriting techniques. IEEE Trans. Knowl. Data Eng. 27(3), 621–635 (2015)CrossRefGoogle Scholar
  17. 17.
    Grohe, M., Marx, D.: Constraint solving via fractional edge covers. ACM Trans. Algor. 11(1), 4 (2014)MathSciNetzbMATHGoogle Scholar
  18. 18.
    Harris, S., Seaborne, A.: SPARQL 1.1 Query Language. W3C Recommendation, W3C, March 2013.
  19. 19.
    Kaminski, M., Kostylev, E.V.: Beyond well-designed SPARQL. In: Proceedings of the ICDT 2016 (to appear, 2016)Google Scholar
  20. 20.
    Kanza, Y., Nutt, W., Sagiv, Y.: Querying incomplete information in semistructured data. J. Comput. Syst. Sci. 64(3), 655–693 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  21. 21.
    Klug, A.C.: On conjunctive queries containing inequalities. J. ACM 35(1), 146–160 (1988)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Kostylev, E.V., Reutter, J.L., Romero, M., Vrgoč, D.: SPARQL with Property Paths. In: Arenas, M., et al. (eds.) The Semantic Web - ISWC 2015. LNCS, vol. 9366, pp. 3–18. Springer, Heidelberg (2015)CrossRefGoogle Scholar
  23. 23.
    Kostylev, E.V., Reutter, J.L., Ugarte, M.: CONSTRUCT queries in SPARQL. In: Proceedings of the ICDT 2015. LIPIcs, vol. 31, pp. 212–229 (2015)Google Scholar
  24. 24.
    Kröll, M., Pichler, R., Skritek, S.: On the complexity of enumerating the answers to well-designed pattern trees. In: Proceedings of the ICDT 2016 (to appear, 2016)Google Scholar
  25. 25.
    Letelier, A., Pérez, J., Pichler, R., Skritek, S.: Static analysis and optimization of semantic web queries. ACM Trans. Database Syst. 38(4), 25 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  26. 26.
    Meier, M.: On the termination of the chase algorithm. Ph.D. Thesis, University of Freiburg (2010).
  27. 27.
    Motik, B., Grau, B.C., Horrocks, I., Wu, Z., Fokoue, A., Lutz, C.: Owl 2 web ontology language: Profiles. W3C working draft, W3C, October 2008.
  28. 28.
    Pérez, J., Arenas, M., Gutierrez, C.: Semantics and complexity of SPARQL. In: Cruz, I., Decker, S., Allemang, D., Preist, C., Schwabe, D., Mika, P., Uschold, M., Aroyo, L.M. (eds.) ISWC 2006. LNCS, vol. 4273, pp. 30–43. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  29. 29.
    Pérez, J., Arenas, M., Gutierrez, C.: Semantics and complexity of SPARQL. ACM Trans. Database Syst. 34(3), 1–45 (2009)CrossRefGoogle Scholar
  30. 30.
    Pichler, R., Skritek, S.: Containment and equivalence of well-designed SPARQL. In: Proceedings of the PODS 2014, pp. 39–50. ACM (2014)Google Scholar
  31. 31.
    Pichler, R., Skritek, S.: On the hardness of counting the solutions of SPARQL queries. In: Proceedings of the AMW 2014. CEUR Workshop Proceedings, vol. 1189. (2014)Google Scholar
  32. 32.
    Polleres, A.: From SPARQl to rules (and back). In: Proceedings of the WWW 2007, pp. 787–796. ACM (2007)Google Scholar
  33. 33.
    Prud’hommeaux, E., Seaborne, A.: SPARQL Query Language for RDF. W3C Recommendation, W3C (2008).
  34. 34.
    Sagiv, Y., Yannakakis, M.: Equivalences among relational expressions with the union and difference operators. J. ACM 27(4), 633–655 (1980)MathSciNetCrossRefzbMATHGoogle Scholar
  35. 35.
    Schmidt, M., Meier, M., Lausen, G.: Foundations of SPARQL query optimization. In: Proceedings of the ICDT 2010, pp. 4–33. ACM (2010)Google Scholar
  36. 36.
    Yannakakis, M.: Algorithms for acyclic database schemes. In: Proceedings of the VLDB 1981, pp. 82–94. IEEE Computer Society (1981)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2016

Authors and Affiliations

  • Shqiponja Ahmetaj
    • 1
  • Wolfgang Fischl
    • 1
  • Markus Kröll
    • 1
  • Reinhard Pichler
    • 1
    Email author
  • Mantas Šimkus
    • 1
  • Sebastian Skritek
    • 1
  1. 1.Database and Artificial Intelligence Group, Faculty of InformaticsTU WienViennaAustria

Personalised recommendations