当前位置: X-MOL 学术J. Autom. Reason. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
A Formalization of SQL with Nulls
Journal of Automated Reasoning ( IF 1.1 ) Pub Date : 2022-07-27 , DOI: 10.1007/s10817-022-09632-4
Wilmer Ricciotti 1 , James Cheney 1
Affiliation  

SQL is the world’s most popular declarative language, forming the basis of the multi-billion-dollar database industry. Although SQL has been standardized, the full standard is based on ambiguous natural language rather than formal specification. Commercial SQL implementations interpret the standard in different ways, so that, given the same input data, the same query can yield different results depending on the SQL system it is run on. Even for a particular system, mechanically checked formalization of all widely-used features of SQL remains an open problem. The lack of a well-understood formal semantics makes it very difficult to validate the soundness of database implementations. Although formal semantics for fragments of SQL were designed in the past, they usually did not support set and bag operations, lateral joins, nested subqueries, and, crucially, null values. Null values complicate SQL’s semantics in profound ways analogous to null pointers or side-effects in other programming languages. Since certain SQL queries are equivalent in the absence of null values, but produce different results when applied to tables containing incomplete data, semantics which ignore null values are able to prove query equivalences that are unsound in realistic databases. A formal semantics of SQL supporting all the aforementioned features was only proposed recently. In this paper, we report about our mechanization of SQL semantics covering set/bag operations, lateral joins, nested subqueries, and nulls, written in the Coq proof assistant, and describe the validation of key metatheoretic properties. Additionally, we are able to use the same framework to formalize the semantics of a flat relational calculus (with null values), and show a certified translation of its normal forms into SQL.



中文翻译:

带有 Null 的 SQL 的形式化

SQL 是世界上最流行的声明性语言,构成了价值数十亿美元的数据库行业的基础。尽管 SQL 已经标准化,但完整的标准是基于模糊的自然语言而不是正式的规范。商业 SQL 实现以不同的方式解释标准,因此,给定相同的输入数据,相同的查询可以根据运行的 SQL 系统产生不同的结果。即使对于特定系统,所有广泛使用的 SQL 功能的机械检查形式化仍然是一个悬而未决的问题。缺乏易于理解的形式语义使得验证数据库实现的可靠性变得非常困难。尽管 SQL 片段的形式语义是在过去设计的,但它们通常不支持集合和包操作、横向连接、嵌套子查询,以及,至关重要的是,空值。空值以类似于空指针或其他编程语言中的副作用的深刻方式使 SQL 的语义复杂化。由于某些 SQL 查询在没有空值的情况下是等价的,但是当应用于包含不完整数据的表时会产生不同的结果,忽略空值的语义能够证明在现实数据库中不可靠的查询等价。支持所有上述功能的 SQL 的形式语义最近才被提出。在本文中,我们报告了在 Coq 证明助手中编写的 SQL 语义的机械化,涵盖集合/包操作、横向连接、嵌套子查询和空值,并描述了关键元理论属性的验证。此外,

更新日期:2022-07-28
down
wechat
bug