Hostname: page-component-76fb5796d-wq484 Total loading time: 0 Render date: 2024-04-25T23:15:42.327Z Has data issue: false hasContentIssue false

Applying Constraint Logic Programming to SQL Semantic Analysis

Published online by Cambridge University Press:  20 September 2019

FERNANDO SÁENZ-PÉREZ*
Affiliation:
Complutense University of Madrid, 28040 Madrid, Spain (e-mail: fernan@sip.ucm.es)

Abstract

This paper proposes the use of Constraint Logic Programming (CLP) to model SQL queries in a data-independent abstract layer by focusing on some semantic properties for signalling possible errors in such queries. First, we define a translation from SQL to Datalog, and from Datalog to CLP, so that solving this CLP program will give information about inconsistency, tautology, and possible simplifications. We use different constraint domains which are mapped to SQL types, and propose them to cooperate for improving accuracy. Our approach leverages a deductive system that includes SQL and Datalog, and we present an implementation in this system which is currently being tested in classroom, showing its advantages and differences with respect to other approaches, as well as some performance data.

Type
Original Article
Copyright
© Cambridge University Press 2019 

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Footnotes

*

Work partially funded by the Spanish Ministry of Economy and Competitiveness, under the grant TIN2017-86217-R (CAVI-ART-2), and by the Madrid Regional Government, under the grant S2018/TCS-4339 (BLOQUES-CM), co-funded by EIE Funds of the European Union. Special thanks are due to the anonymous referees.

References

Allen, G. N. 2000. WebSQL: An Interactive Web Tool for Teaching Structured Query Language. In Proceedings of Americas’ Conference on Information Systems (AMCIS 2000).Google Scholar
Apt, K. 2003. Principles of Constraint Programming. Cambridge University Press, NY, USA.Google Scholar
Brass, S. and Goldberg, C. 2005. Proving the safety of SQL queries. In Fifth International Conference on Quality Software (QSIC’05). 197–204.Google Scholar
Brass, S. and Goldberg, C. 2006. Semantic Errors in SQL Queries: A Quite Complete List. The Journal of Systems and Software 79, 5, 630644.Google Scholar
Burstall, R. M. and Darlington, J. 1977. A transformation system for developing recursive programs. Journal of the ACM 24, 1, 4467.Google Scholar
Caballero, R. and Ieva, C. 2015. Constraint Programming Meets SQL. In XV Jornadas sobre Programación y Lenguajes, PROLE 2015 (SISTEDES).Google Scholar
Correas, J., Estévez-Martín, S., and Sáenz-Pérez, F. 2018. Enhancing set constraint solvers with bound consistency. Expert Systems with Applications 92, 485494.Google Scholar
Dollinger, R. 2010. SQL Lightweight Tutoring Module – Semantic Analysis of SQL Queries based on XML Representation and LINQ. In Proceedings of EdMedia 2010. Toronto, Canada, 3323–3328.Google Scholar
Estévez-Martín, S., Fernández, A. J., Sáenz-Pérez, F., Hortalá-González, T., Rodríguez-Artalejo, M., and del Vado Vrseda, R. 2009. On the Cooperation of the Constraint Domains, and in. Theory and Practice of Logic Programming 9:4, 415527.Google Scholar
Gatterbauer, W. 2011. Databases will Visualize Queries too. Proceedings of the VLDB Endowment 4, 12, 14981501.Google Scholar
Guagliardo, P. and Libkin, L. 2017. A Formal Semantics of SQL Queries, Its Validation, and Applications. Proceedings of the VLDB Endowment 11, 1, 2739.Google Scholar
Guo, S., Sun, W., and Weiss, M. A. 1996. Solving satisfiability and implication problems in database systems. ACM Transactions on Database Systems 21, 270293.Google Scholar
Hofstedt, P. 2000. Cooperating Constraint Solvers. In Sixth International Conference on Principles and Practice of Constraint Programming – CP, R. Dechter, Ed. LNCS, vol. 1894. Springer-Verlag.Google Scholar
ISO/IEC. 2016. SQL:2016 ISO/IEC 9075-1:2016 Standard.Google Scholar
Jaffar, J. and Lassez, J.-L. 1987. Constraint logic programming. In Proc. of the 14th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages. POPL ’87. ACM, 111–119.Google Scholar
Javid, M., Embury, S., Srivastava, D., and Ari, I. 2012. Diagnosing faults in embedded queries in database applications. ACM, 239244.Google Scholar
Mitrovic, A. 2012. Fifteen years of constraint-based tutors: what we have achieved and where we are going. User Modeling and User-Adapted Interaction 22, 1, 3972.Google Scholar
Monfroy, E. and Castro, C. 2004. A component language for hybrid solver cooperations. In ADVIS. Lecture Notes in Computer Science, vol. 3261. Springer, 192–202.Google Scholar
Prior, J. R. 2014. AsseSQL: An Online, Browser-based SQL Skills Assessment Tool. In Proceedings of the 2014 Conference on Innovation & Technology in Computer Science Education. ITiCSE ’14. ACM, New York, NY, USA, 327–327.Google Scholar
Sadiq, S., Orlowska, M., Sadiq, W., and Lin, J. 2004. SQLator: An Online SQL Learning Workbench. SIGCSE Bulletin 36, 3, 223227.Google Scholar
Sáenz-Pérez, F. 2011. DES: A Deductive Database System. Electronic Notes on Theoretical Computer Science 271, 6378.Google Scholar
Sáenz-Pérez, F. 2017. Intuitionistic Logic Programming for SQL. In Logic-Based Program Synthesis and Transformation, Hermenegildo, M. V. and López-Garca, P., Eds. Springer, 293308.Google Scholar
Sáenz-Pérez, F. 2019. Experiencing Intuitionistic Logic Programming in SQL Puzzles (Work In Progress). In XIX Conference on Programming and Languages, PROLE’2019 (SISTEDES). In Press.Google Scholar
Scott, J. D., Flener, P., and Pearson, J. 2013. Bounded strings for constraint programming. In 2013 IEEE 25th International Conference on Tools with Artificial Intelligence. 1036–1043.Google Scholar
Sterling, L. and Shapiro, E. 1994. The Art of Prolog (2nd Ed.): Advanced Programming Techniques. MIT Press, Cambridge, MA, USA.Google Scholar
Tamaki, H. and Sato, T. 1984. Unfold/fold transformations of logic programs. In Proceedings of the International Conference on Logic Programming. 127–138.Google Scholar
Ullman, J. D. 1988. Principles of Database and Knowledge-Base Systems. Computer Science Press.Google Scholar