English

Verifying SQL Queries using Theories of Tables and Relations

Logic in Computer Science 2024-05-28 v2

Abstract

We present a number of first- and second-order extensions to SMT theories specifically aimed at representing and analyzing SQL queries with join, projection, and selection operations. We support reasoning about SQL queries with either bag or set semantics for database tables. We provide the former via an extension of a theory of finite bags and the latter via an extension of the theory of finite relations. Furthermore, we add the ability to reason about tables with null values by introducing a theory of nullable sorts based on an extension of the theory of algebraic datatypes. We implemented solvers for these theories in the SMT solver cvc5 and evaluated them on a set of benchmarks derived from public sets of SQL equivalence problems.

Keywords

Cite

@article{arxiv.2405.03057,
  title  = {Verifying SQL Queries using Theories of Tables and Relations},
  author = {Mudathir Mohamed and Andrew Reynolds and Cesare Tinelli and Clark Barrett},
  journal= {arXiv preprint arXiv:2405.03057},
  year   = {2024}
}
R2 v1 2026-06-28T16:17:23.616Z