Preprint.
SynSQL: Synthesizing Relational Databases for Robust Evaluation of Text-to-SQL Systems Mohammadamin Habibollah, Davood Rafiei Department of Computing Science University of Alberta {mhabibol, drafiei}@ualberta.ca
arXiv:2604.27261v1 [cs.DB] 29 Apr 2026
Abstract Evaluating text-to-SQL systems remains largely fragile: correctness is typically judged by executing predicted and gold SQL queries on a single static database, even though the same queries may behave differently under alternative database instances. This raises a broader language modeling question: Can large language models synthesize semantically meaningful, schema-consistent relational data directly from a natural language question? If so, such generation can serve as a controlled mechanism for stress-testing text-to-SQL systems beyond fixed benchmark databases. We introduce SynSQL, a framework that synthesizes test databases conditioned on question–schema alignment rather than gold SQL queries. SynSQL decomposes the task into three stages: (1) schema selection, (2) question-guided data synthesis, and (3) constraint-aware critique with iterative refinement, framing database construction as structured generation under semantic and relational constraints. Across ten text-to-SQL models on Spider, BIRD, and Spider 2.0, SynSQL-generated databases reveal performance drops of 3–14% compared to static evaluation, exposing errors masked by benchmark artifacts. We further analyze generation quality, constraint adherence, and failure modes, highlighting both the promise and limitations of LLMs in structured data synthesis. Our findings position synthetic database generation as a new lens for studying LLM reasoning, controllability, and robustness in structured environments.
1
Introduction
Text-to-SQL benchmarks such as Spider (Yu et al., 2018) and BIRD (Li et al., 2023b) have driven rapid progress by pairing natural language (NL) questions with gold SQL queries over curated relational databases. Evaluation is typically conducted by executing predicted and gold queries against a single fixed database instance and comparing their outputs. While effective for standardization, this setup implicitly assumes that correctness is invariant to the underlying database content. In practice, this assumption is fragile, and execution outcomes can depend heavily on the specific database instance (Mitsopoulou & Koutrika, 2025; Renggli et al., 2025). Issues such as referential integrity violations, unexpected NULL values, case mismatches between questions and database content, or noisy entries may cause incorrect queries to appear correct (false positives) or semantically valid queries to be penalized (false negatives). As a result, evaluation reflects not only language understanding and query reasoning, but also the particular “world” encoded by the benchmark database (Zhong et al., 2020). This fragility suggests a broader perspective: evaluation can be viewed as a data generation problem. Instead of asking whether a predicted query matches a gold query on a single database, we should ask whether it remains correct across semantically meaningful variations of the underlying data, an important but underexplored aspect of text-to-SQL evaluation. Prior approaches to generating alternative databases are gold query-centric. Systems such as AGENDA (Deng et al., 2005), XData (Veanes et al., 2010), and TestSuiteAccuracy (Zhong et al., 2020) construct counterexample databases by mutating gold SQL 1
Preprint.
What is the average lap time for Lewis Hamilton in the 2009 Malaysian Grand Prix? Key Values Extraction: ["Lewis", "Hamilton", "2009", "Malaysian Grand Prix"] Ensemble Column Selection: ["drivers.driverId", "drivers.forename", "drivers.surname", ... ] ["drivers.forename", "drivers.surname", "races.year", "races.name", ... ] ["drivers.forename", "drivers.surname", "lapTimes.milliseconds", ... ] Column Expansion: ["lapTimes.raceId", "seasons.year", "circuits.name"]
FULL SCHEMA
INSERT INTO "races" VALUES ("101", "2009", "Malaysian Grand Prix"); INSERT INTO "races" VALUES ("102", "2009", "Australian Grand Prix"); INSERT INTO "drivers" VALUES ("44", "Lewis", "Hamilton"); INSERT INTO "drivers" VALUES ("5", "Sebastian", "Vettel"); INSERT INTO "lapTimes" VALUES ("101", "44", "1", "90000"); INSERT INTO "lapTimes" VALUES ("101", "44", "1", "89500");
REDUCED SCHEMA
REDUCED SCHEMA + [FEEDBACKS]
INSERT STATEMENTS
FEEDBACKS
DATA
(IF APPLICABLE)
+
Ratings: Key Integrity: ?/10 Complexity: ?/10 Variety: ?/10 ... Feedbacks: Ensure that the "lapTimes" keys are unique and consistent across "races" and "drivers" tables to maintain foreign key integrity.
INSERT
REDUCED SCHEMA
ratings feedback
Schema Selector
Synthesizer
DATABASE
Critic
Figure 1: Overview of the SynSQL framework. The schema selector identifies relevant schema elements and reduces the schema space. The synthesizer generates test data based on the NL question and reduced schema. The critic evaluates the quality of the generated data and provides feedback for improvement. queries or by symbolically analyzing them to distinguish correct from incorrect variants. More recent SMT-based approaches (e.g., VeriEQL (He et al., 2024) and SpotIt (Klopfenstein et al., 2025)) synthesize databases that distinguish predicted queries from reference queries. While powerful, these methods rely on access to gold SQL and are limited by bounded verification and query complexity. More fundamentally, they leave open a key question: can relational test data be generated directly from natural language and schema structure? In this work, we investigate whether large language models (LLMs) can synthesize semantically grounded, schema-consistent relational databases conditioned only on a natural language question and a database schema. If feasible, such question-conditioned generation serves two purposes. First, it enables robustness evaluation of text-to-SQL systems without relying on gold query annotations and their mutations. Second, it probes an emerging capability of LLMs: structured world modeling under relational constraints. Generating a database from a question requires identifying relevant schema elements, populating tables with coherent and discriminative values, enforcing integrity constraints (e.g., foreign keys and uniqueness), and encoding semantic signals that expose query errors. This reframes database synthesis as a controlled structured generation task that jointly tests semantic grounding and constraint awareness. We introduce SynSQL, a modular framework for question-conditioned synthetic database generation. SynSQL decomposes the task into three stages (Figure 1): a Schema Selector identifies schema elements relevant to the question, reducing the combinatorial search space; a Synthesizer generates relational tuples conditioned on the question and the reduced schema; and a Critic enforces structural consistency and semantic alignment, iteratively refining the generated database. This design treats database construction as an interactive structured generation process that integrates language-based reasoning with relational constraints. We evaluate SynSQL across ten text-to-SQL systems on Spider, BIRD, and Spider 2.0. SynSQL-generated databases reveal consistent robustness gaps: model accuracies drop by 3–14% compared to evaluation on the original static databases, and in some cases lead to changes in model ranking. This indicates that fixed benchmark instances mask systematic errors. At the same time, SynSQL achieves high constraint satisfaction rates and produces realistic, minimal databases aligned with question semantics. Our analysis highlights both the strengths and limitations of LLMs in structured data synthesis, including failure modes in constraint adherence and semantic grounding under complex schemas. Contributions. This paper makes the following contributions: (1) We introduce questionconditioned relational database synthesis from natural language and schema as a new task for 2
Preprint.
studying the ability of LLMs to construct semantically grounded relational worlds under structural constraints. (2) We develop S YN SQL, a modular framework that decomposes this task into schema selection, question-guided synthesis, and constraint-aware critique with iterative refinement. (3) Through extensive evaluation across multiple text-to-SQL systems, datasets, and LLM families, we show that SynSQL exposes robustness gaps and induces ranking shifts under structurally valid data variation that are not apparent under static evaluation. (4) We provide a detailed analysis of structural validity, semantic support, and failure modes, offering insight into where LLMs succeed and where they remain limited in structured world generation.
2
Related Work
Evaluation and query-centric database generation. Text-to-SQL systems are typically evaluated by executing predicted and gold SQL queries on a fixed database instance, as in Spider (Yu et al., 2018) and BIRD (Li et al., 2023b). While this enables standardized comparison, execution-based evaluation is sensitive to the underlying data and may overestimate correctness due to coincidental agreement on specific instances (Mitsopoulou & Koutrika, 2025; Renggli et al., 2025; Zhong et al., 2020). To address this, prior work generates alternative databases that distinguish correct from incorrect queries. Systems such as AGENDA (Deng et al., 2005), XData (Veanes et al., 2010), and TestSuiteAccuracy (Zhong et al., 2020) use query mutation or symbolic analysis, while SMT-based approaches (e.g., VeriEQL (He et al., 2024) and SpotIt (Klopfenstein et al., 2025)) synthesize counterexample databases. These methods are inherently query-centric, requiring access to gold SQL and reasoning over query structure, which limits scalability and generality. LLMs for data and structured generation. Recent work explores LLMs for synthetic data generation, including controllable generation (Zhou et al., 2025) and unified dataset pipelines (Huang et al., 2024). In parallel, LLMs have shown strong capabilities in generating structured outputs such as code, tables, and semi-structured data (Chen et al., 2021; Austin et al., 2021; Li et al., 2023c), with applications in program synthesis (Chen et al., 2021; Austin et al., 2021), table reasoning (Yin et al., 2020; Herzig et al., 2020), and tool use (Schick et al., 2023). Recent work (e.g., StructSynth (Liu et al., 2025)) highlights the difficulty of enforcing structural dependencies in tabular generation. However, these approaches either focus on matching data distributions or generating isolated structured outputs, and do not address relational data generation grounded in natural language and constrained by schema structure. Our approach. We frame relational database construction as a structured generation problem conditioned on natural language and schema. Unlike prior work, we synthesize schema-consistent databases directly from question-schema alignment, without relying on gold queries. This enables evaluation under controlled data variation and provides a testbed for studying how LLMs align language with relational structure under constraints.
3
Methodology
We formulate question-conditioned database synthesis as a structured generation problem over relational database instances. Given a natural language question q and a database schema S , the goal is to generate a database instance D such that (i) D satisfies the structural constraints of S (e.g., primary and foreign keys), and (ii) D encodes semantic signals implied by q that enable distinguishing correct and incorrect query interpretations. We introduce S YN SQL, a modular framework that decomposes this process into three stages (Figure 1): schema selection, question-conditioned data synthesis, and constraint-aware critique, which together reduce the generation space, construct candidate data, and enforce structural and semantic validity. 3
Preprint.
3.1
Schema Selection
Real-world database schemas often contain many tables and columns, while most NL questions reference only a small subset. Providing the full schema can lead to unnecessary or inconsistent data generation (e.g., foreign key violations). The goal is therefore to identify relevant schema elements while preserving sufficient context for coherent synthesis. Given S and q, we select a subset S ′ ⊆ S by grounding linguistic cues in q to tables, attributes, and relationships. This reduces the combinatorial search space while retaining the structure needed for synthesis. We implement schema selection using an LLM that identifies relevant elements based on lexical overlap, semantic similarity, and relational context (§ A.10,A.11). Our approach prioritizes recall, retaining all schema elements that could plausibly support data synthesis. As outlined in Algorithm 1 (Appendix), we adopt an ensemble-expansion strategy: the LLM is queried multiple times at different temperature settings to produce diverse candidate subsets, whose union forms a high-recall core. This core is then expanded with semantically or functionally related columns to further improve coverage. 3.2
Question-Conditioned Data Synthesis
Unlike prior approaches that rely on reference SQL queries or their mutations, our synthesizer operates directly from q and S ′ , enabling broader coverage of query semantics. Given S ′ and q, the synthesizer generates a database instance D by populating each table with tuples. This requires generating values that are: (i) structurally valid, respecting column types and table schemas, (ii) relationally consistent, maintaining dependencies such as foreign keys, and (iii) semantically grounded in q, including values that can expose potential errors in query interpretation. We leverage the LLM to generate table-by-table tuples conditioned on q and S ′ , while maintaining consistency between tables through key relationships and value-level dependencies (e.g., foreign keys, aligned attributes and correlated values across tables) (§ A.12). We apply lightweight postprocessing to enforce basic structural correctness, including dropping tables or columns not in the schema, enforcing arity (padding with NULLs or truncating as needed), and normalizing values based on keywords extracted from the question. This process ensures the database can be loaded and executed, but cannot resolve referential integrity violations or semantic misalignment, which require regenerating coherent tuples and are addressed in the next stage. 3.3
Constraint-Aware Critique and Refinement
Key or referential integrity violations (e.g., foreign keys pointing to missing rows) cannot be fixed by dropping columns; they require the synthesizer to produce a new, consistent set of rows. Similarly, misalignment with question hints, lack of data variety, and oversimplified patterns that inflate success rate without improving discriminative power are semantic issues that only iterative refinement can address. Inspired by self-correction for LLMs (Pan et al., 2023), we therefore introduce a Critic that evaluates each generated database and decides whether to accept it or request a new round of generation. It scores the data on a 1–10 scale across six dimensions: alignment with question hints, key and referential integrity, schema coverage, data complexity, variety in records, and overall relevance. It translates detected issues into targeted feedback for refinement. If the average score meets the quality threshold (e.g., 8.0), the data is accepted; otherwise, the feedback is incorporated into the next iteration (see Appendix A.7 for details). Discussion: This formulation casts database construction as a structured generation problem requiring LLMs to jointly reason over language, schema structure, and relational constraints. Unlike query-centric approaches that derive test data from SQL, SynSQL generates relational instances directly from question–schema alignment, enabling controlled variation of underlying data and more robust evaluation of text-to-SQL systems. 4
Preprint.
4
Experimental Evaluation
Our experimental evaluation aims to address three core questions: (i) Can LLMs generate relational databases that are executable, structurally valid, and semantically supportive? (ii) Do such databases reveal robustness failures not observable under fixed-instance evaluation? (iii) How do SynSQL’s components affect generation quality? 4.1
Experimental Setup
Datasets. We evaluate SynSQL on three widely used text-to-SQL benchmarks: Spider (Yu et al., 2018), BIRD (Li et al., 2023b), and Spider 2.0 (Lei et al., 2024). Spider features simple schemas, while BIRD includes complex queries with joins and nested subqueries. Spider 2.0-SQLite contains 135 enterprise-level problems requiring handling of complex schemas and multi-step queries. This enables comprehensive assessment across varying schema complexity. Model Configuration. We instantiate SynSQL using a mix of proprietary and open-source language models, including GPT-4.1-mini, Gemini-2.5-Flash, Gemini-3-Flash, and Qwen-38B. The critic performs up to three refinement iterations and terminates early if the generated database achieves a quality score of 8.0 or higher (on a 10-point scale). As a baseline, we use a vanilla synthesizer that generates data in a single pass without schema reduction or critic feedback. This baseline is equivalent to SynSQL without schema selection, data validation, or iterative refinement, operating over the full schema with the same prompting strategy. Text-to-SQL Systems. To evaluate the effectiveness of SynSQL-generated databases in distinguishing correct and incorrect queries, we use ten competitive text-to-SQL systems to produce candidate SQL queries: OmniSQL-32B (Li et al., 2025b), RSL-SQL + GPT-4o (Cao et al., 2024), Alpha-SQL + Qwen-32B (Li et al., 2025a), CSC-SQL + Qwen-32B (Sheng & Xu, 2025), Gemini-SQL (Multitask SFT + Gemini-2.5-Pro) (Pourreza & Kubik, 2025), DIN-SQL (Pourreza & Rafiei, 2023), DAIL-SQL (Gao et al., 2023),Graphix-3B+PICARD (Li et al., 2023a), C3 + ChatGPT (Dong et al., 2023), and GPT 5.4. Evaluation Metrics. We employ three complementary metrics to assess both the quality of the generated databases and their utility for evaluating text-to-SQL systems: Success Rate (SR). SR measures the fraction of questions for which the gold SQL query produces a non-empty result on the generated database. This indicates whether the synthesized data captures the semantic intent of the natural language question, as expressed by the gold query. Random or poorly aligned data often yields empty results, making SR a necessary but weak proxy for semantic grounding. Execution Accuracy (EX). EX is the standard metric used in Spider and BIRD. It measures the fraction of questions for which the model-generated SQL query produces the same result as the gold SQL query when executed on a single database instance. EX characterizes model behavior under a fixed database, rather than serving as the primary comparison metric. Compound Execution Accuracy (EXc ). EXc extends EX by requiring correctness across both the original benchmark database and the SynSQL-generated database. A prediction is counted as correct only if it produces the same result as the gold SQL query on both instances; otherwise, it is considered incorrect. Thus EXc measures robustness under data variation and is upper-bounded by EX on either database alone. 4.2
Robustness Under Data Variation
Tables 1, 2, and 3 show that requiring correctness across both the original and SynSQLgenerated database instances leads to consistent and substantial performance drops across all models and datasets. On BIRD, compound execution accuracy (EXc ) decreases by 69% relative to the official execution accuracy, revealing errors that are not exposed under standard single-instance evaluation. Similar trends are observed on Spider and Spider 2.0, 5
Preprint.
confirming that this phenomenon is dataset-independent. This gap highlights a fundamental limitation of the commonly-used execution accuracy (EX): it evaluates correctness on a single data instance and can overestimate performance due to coincidental agreement. In contrast, EXc requires correctness across multiple semantically valid database instantiations, providing a stricter and more reliable measure of semantic correctness. Table 1: Drop in execution accuracy (∆EXc) relative to BIRD (Original). Rankings are shown per row (lower drop is better). Method
OmniSQL RSL-SQL Alpha-SQL CSC-SQL Gemini-SQL
BIRD (Original)
66.75 (5)
67.47 (4)
69.23 (3)
71.06 (2)
72.10 (1)
Vanilla GPT-4.1-Mini Vanilla Gemini-2.5-Flash SynSQL (Qwen-3-8B) SynSQL (Gemini-2.5-Flash) SynSQL (GPT-4.1-Mini)
-3.52 (5) -3.13 (5) -7.56 (5) -6.97 (5) -8.21 (5)
-3.39 (4) -2.93 (4) -6.39 (4) -6.42 (4) -7.43 (4)
-3.65 (3) -3.06 (3) -7.63 (3) -6.78 (3) -8.80 (3)
-3.92 (2) -3.52 (2) -6.70 (2) -7.70 (2) -9.07 (2)
-2.61 (1) -2.28 (1) -5.48 (1) -5.67 (1) -6.34 (1)
Table 2: Drop in execution accuracy (∆EXc) relative to Spider (Original). Rankings are shown per row. Method
Graphix
Spider (Original)
77.51 (4) 77.76 (3)
C3
80.46 (2)
80.66 (1)
Vanilla GPT-4.1-Mini Vanilla Gemini-2.5-Flash SynSQL (Qwen-3-8B) SynSQL (Gemini-2.5-Flash) SynSQL (GPT-4.1-Mini)
-2.36 (3) -2.46 (3) -3.14 (3) -2.95 (3) -3.14 (3)
-2.48 (2) -2.80 (2) -3.44 (2) -3.19 (2) -4.15 (2)
-2.03 (1) -1.94 (1) -3.00 (1) -2.42 (1) -3.10 (1)
-3.58 (4) -2.52 (4) -6.10 (4) -5.13 (4) -5.71 (4)
DIN-SQL DAIL-SQL
Performance Gap and Model ranking. Table 3: Drop in execution accuracy (∆EXc) Model rankings remain largely stable on relative to Spider 2.0-SQLite (Original). BIRD and Spider 2.0, although we observe OmniSQL GPT 5.4 significant changes in performance gaps be- Method tween models. However, on Spider even Spider 2.0 (Original) 12.59 (2) 40.00 (1) the ranking among models changes. This -1.48 (2) -8.15 (1) suggests that performance and ranking sta- Vanilla GPT-4.1-Mini Vanilla Gemini-3-Flash -3.7 (2) -12.59 (1) bility is subject to change, with data variaSynSQL (GPT-4.1-Mini) -2.97 (2) -10.37 (1) tion having a greater impact when compet- SynSQL (Gemini-3-Flash) -5.18 (2) -14.07 (1) ing models exhibit similar performance on a single database instance. In such cases, evaluating across multiple database instances reveals finer-grained differences that are otherwise hidden. Under SynSQL, Graphix is ranked above C3 on Spider, reversing their order under the official evaluation and exposing errors masked by single-instance testing. 4.3
Quality of Synthesized Databases
SynSQL can also serve as a standalone data synthesizer when human-curated databases are not available. We therefore evaluate the quality of SynSQL-generated data by comparing it against both human-curated databases and vanilla LLM-based baselines. Success Rate. As shown in Table 5 (Appendix), SynSQL achieves success rates of 82.07% on BIRD, 93.04% on Spider, and 80.0% on Spider 2.0, consistently outperforming vanilla baselines across all datasets and LLM families. Notably, on Spider, SynSQL even surpasses the original human-authored database (92.55%) when paired with Gemini-2.5-Flash and GPT-4.1-Mini. This improvement can be attributed to inconsistencies in the benchmark data, such as missing values and formatting artifacts (e.g., trailing spaces), which can lead 6
Preprint.
to unintended empty results during execution. By synthesizing clean and semantically aligned data, SynSQL mitigates these issues and better reflects the intent of the underlying queries. Illustrative examples of such inconsistencies are provided in Figures 18 and 19 in the Appendix. Execution Accuracy. We further evaluate execution accuracy (EX) on each method’s generated database (Table 5 in the Appendix). SynSQL yields EX values that are close to those on the original human-curated databases across BIRD, Spider, and Spider 2.0, while remaining consistently lower than vanilla baselines. Here, lower EX indicates a more discriminative evaluation setting. We observe higher EX for vanilla baselines, particularly on BIRD and Spider, indicating that their generated data fails to effectively discriminate between correct and incorrect queries. In contrast, SynSQL maintains high SR while producing more demanding databases, resulting in lower but more informative EX. Importantly, these differences are not due to invalid data: SynSQL-generated databases remain executable, structurally valid, and semantically supportive. Overall, this demonstrates that SynSQL enables more faithful and rigorous execution-based evaluation. Structural Validity. Figure 4 (Appendix) presents the percentage of generated databases that adhere to schema constraints, including primary and foreign key integrity and table structure, are executable and have valid data. SynSQL achieves near-perfect validity (99% across all datasets), improving over vanilla LLM baselines by 30–33% on BIRD, 9–20% on Spider, and 18–25% on Spider 2.0. The gains are most pronounced on schema-complex datasets such as BIRD and Spider 2.0, highlighting the difficulty of maintaining inter-table dependencies without explicit schema-aware guidance. These results demonstrate that, with schema reduction and iterative refinement, LLMs can reliably generate data that respects both structural constraints and inter-table dependencies. Combined with strong SR and EX performance, this confirms that SynSQL produces databases that are not only semantically meaningful but also structurally sound. 4.4
Failure Analysis
Despite strong overall performance, a systematic analysis reveals recurring failure modes that expose fundamental limitations of LLM-based structured data generation. To understand where synthesis fails to capture the structural or semantic cues of the NL question, we analyzed success rate failures on a random sample of 500 BIRD questions. Of these, 84 cases yield empty results when executing the gold query on the SynSQL-generated database. Figure 2(a) summarizes the breakdown of these failures and highlights two primary sources of error. Adherence to Schema Constraints. In these cases, the schema selection omits one or more tables or columns required by the gold query, preventing the synthesized database from supporting the intent of the question. For example, if the gold query references a player table but the schema selector fails to include it in the reduced schema, the generated database will lack the necessary structure to yield a non-empty result. These failures highlight the difficulty of high-recall schema selection under complex schemas with many tables and columns. Semantic Failures. Here the generated data is structurally valid and executable, but the instantiated values do not align with the expectations of the gold query. Common issues are case mismatches (e.g., owner vs. OWNER), differences in value granularity (e.g., Prague 1 vs. Prague), and inconsistencies with benchmark-specific conventions. Among the 44 semantic failures, 27 are attributable to SynSQL generation, while the remaining 17 stem from ambiguous or inconsistent question–query pairs in the BIRD dev set. These cases illustrate the difficulty of grounding generated values to a single “correct” interpretation when the question or gold query is underspecified. Overall, these failure modes reveal two key challenges in question-conditioned database synthesis: (i) achieving high-recall schema selection without access to gold queries, and (ii) 7
Preprint.