Data Transformation to Construct a Dataset for Generating Entity-Relationship Model from Natural Language

Zhenwen Li, Jian-Guang Lou, Tao XiearXiv 2023 · DOI

Introduction

Designing an Entity-Relationship (ER) model is a fundamental step in database development, serving as the conceptual blueprint for data organization. However, this process is traditionally manual, time-consuming, and requires significant domain expertise. While the automation of this task—referred to as Natural Language to Entity-Relationship Model (NL2ERM)—has been a research goal for years, progress has been stalled by two major hurdles: a reliance on rigid, rule-based heuristic systems and a critical lack of large-scale, annotated training data.

Rule-based systems often fail to generalize across the inherent variability of natural language. For example, a system programmed to recognize the word "has" as a relationship indicator might fail when a user uses synonyms like "possesses" or "contains." Deep learning models offer a potential solution to this generalization problem, but their effectiveness is predicated on the availability of massive datasets. Until now, NL2ERM research has relied on tiny, often private datasets with fewer than 50 entries, making it impossible to train modern information extraction (IE) architectures.

The Data Transformation Pipeline

To address the data scarcity problem, this research introduces a novel data transformation algorithm that repurposes existing text-to-SQL datasets, such as the widely used Spider dataset, into fine-grained NL2ERM training data. The core insight is that a database schema is essentially a realized ER model; by reversing the engineering process, researchers can unlock thousands of existing examples for training.

The three-step data transformation pipeline: Database to Raw ER Model, Schema Linking, and Final ER Model construction.

As illustrated in the pipeline above, the transformation consists of three primary stages:

  1. Database to Raw ER Model: The algorithm maps database tables to entities, columns to attributes, and foreign keys to relationships. A critical component of this step is the identification of "relation tables"—tables that exist solely to facilitate many-to-many relationships. These are converted into direct entity-to-entity relationships rather than being treated as standalone entities.
  2. Schema Linking: To create token-level annotations, the algorithm matches words in the natural language utterance to specific database elements. Uniquely, the authors use the associated SQL query as a "gold standard" guide. Since the SQL query explicitly names the tables and columns required to answer a prompt, it provides an unambiguous map for which tokens in the sentence should be labeled as entities or attributes.
  3. Pruning: The final step involves removing any entities or attributes from the model that are not explicitly mentioned in the natural language text, ensuring the ground truth model is a perfect reflection of the user's description.
An example of mapping database structures (tables and foreign keys) to ER model components (entities and relationships).

Experimental Results and Generalization

The authors evaluated their approach by training two state-of-the-art IE models, UIE and REBEL, on the newly transformed dataset. The results demonstrated a significant leap over traditional methods. On the primary test set derived from Spider, the deep learning models achieved F1-scores between 0.76 and 0.78 for entity and attribute extraction. In contrast, rule-based baselines like ER-Gen and Scenario-ER struggled immensely, particularly with relationship extraction, where they scored as low as 0.06.

Beyond standard performance, the models showed remarkable robustness. When tested on specialized benchmarks—including software requirements for banking systems and scenario descriptions from database textbooks—the models maintained high performance, with F1-scores reaching up to 0.87. This suggests that the linguistic patterns used to describe data structures are consistent enough that models trained on simple questions (from Spider) can generalize to complex technical requirements.

Conclusion and Future Work

This work represents a significant milestone in automating database design. By creating the first large-scale dataset for NL2ERM through clever data transformation, the authors have enabled the application of modern deep learning to a previously stagnant field.

While the current model excels at identifying entities and attributes, it does not yet extract "cardinality" (e.g., one-to-one vs. many-to-many relationships) due to limitations in the source datasets. Future research will focus on augmenting the dataset with cardinality annotations and exploring more complex linguistic structures found in professional software engineering documentation.

Summary updated

BibTeX
@misc{li2023data,
  author = {Zhenwen Li and Jian-Guang Lou and Tao Xie},
  title = {{Data Transformation to Construct a Dataset for Generating Entity-Relationship Model from Natural Language}},
  year = {2023},
  eprint = {2312.13694},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.13694},
}
Figure