# Applying Constraint Logic Programming to SQL Semantic Analysis

**Authors:** Fernando S\'aenz-P\'erez

arXiv: 1907.10914 · 2020-02-19

## TL;DR

This paper introduces a novel approach using Constraint Logic Programming to analyze SQL queries for semantic errors by translating SQL to Datalog and CLP, enabling error detection and query simplification.

## Contribution

It presents a new method combining SQL, Datalog, and CLP with multiple constraint domains to improve semantic analysis accuracy of SQL queries.

## Key findings

- Implementation shows advantages over existing methods.
- System detects inconsistencies and tautologies in SQL.
- Performance data indicates efficiency in classroom testing.

## 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. This paper is under consideration for acceptance in TPLP.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1907.10914/full.md

## Figures

6 figures with captions in the complete paper: https://tomesphere.com/paper/1907.10914/full.md

## References

27 references — full list in the complete paper: https://tomesphere.com/paper/1907.10914/full.md

---
Source: https://tomesphere.com/paper/1907.10914