arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.03145cs.DB
收藏

面向文本到SQL的友好逻辑数据库设计

The Case for Text-to-SQL Friendly Logical Database Design

Simon Fraser University(西蒙菲莎大学);Tsinghua University(清华大学)

Shi Heng Zhang, Zhengjie Miao, Jiannan Wang

AI总结:

本文提出LLM友好的逻辑数据库设计目标,通过三种语义保持的模式变换(抽象、分区、重命名)优化数据库模式,提升文本到SQL的生成准确率,实验显示执行准确率提升高达4.2%。

摘要:

传统逻辑数据库设计优化数据库模式(包括表、列、键、约束和视图)以确保正确性、完整性并支持人工编写的应用查询。基于LLM的文本到SQL改变了使用者:模式现在通常由语言模型以文本形式读取,因此保持数据库语义的设计选择仍可改变SQL生成的准确性。我们认为这创造了一个新的设计目标,与经典目标并列——LLM友好的逻辑数据库设计,即模式易于语言模型从自然语言映射到正确SQL的属性,并将其作为本文的优化目标。我们通过三种语义保持的模式变换来实例化该目标,这些变换重新利用了经典模式设计思想:模式抽象(+A:物化重复连接路径的逻辑视图)、模式分区(+P:感知工作负载的逻辑分区,修剪不相关上下文)和模式重命名(+R:改进下游列链接和谓词构建的描述性标识符)。这三个算子可组合,且每个都保持底层数据库语义。当历史问题-SQL对可用时,它们指导分区和抽象;在零样本设置中,重命名直接应用,抽象退化为针对每个问题的临时变体。我们在BIRD-Union和Spider-Union上评估了生成的模式,跨越多个文本到SQL流水线和语言模型骨干,执行准确率提升高达4.2%。最佳变换在不同流水线和模型间略有变化,完整的+A+P+R持续改进;多个算子组合在每个流水线上都具有竞争力。这些结果表明,LLM友好的逻辑设计是一个实用且未被充分探索的数据库端优化目标,与现有文本到SQL流水线互补。

英文摘要:

Logical database design has traditionally optimized database schemas, including tables, columns, keys, constraints, and views, for correctness, integrity, and human-written application queries. LLM-based Text-to-SQL changes the consumer: the schema is now often read as text by a language model, so design choices that preserve database semantics can still change SQL-generation accuracy. We argue that this creates a new design objective alongside the classical ones - LLM-friendly logical database design, the property that a schema is easy for a language model to map from natural language to correct SQL - and treat it as the optimization target of this paper. We instantiate this objective with three semantics-preserving schema transformations that re-purpose classical schema-design ideas: schema abstraction (+A: logical views that materialize recurring join paths), schema partitioning (+P: workload-aware logical partitions that prune irrelevant context), and schema renaming (+R: descriptive identifiers that improve downstream column linking and predicate construction). The three operators compose, and each preserves the underlying database semantics. When historical question-SQL pairs are available, they guide both partitioning and abstraction; in zero-shot settings, renaming applies directly, and abstraction falls back to an ad-hoc per-question variant. We evaluate the resulting schemas on BIRD-Union and Spider-Union across multiple Text-to-SQL pipelines and language model backbones, with gains of up to 4.2% in execution accuracy. The best transformation varies modestly across pipelines and models, with the full +A+P+R consistently improving; multiple operator combinations are competitive on each pipeline. These results show that LLM-friendly logical design is a practical and underexplored database-side optimization target, complementary to existing Text-to-SQL pipelines.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑