Automatically Inferring Database Schemas

Sitaram Lanka

In 1984, Sitaram Lanka of the University of Pennsylvania proposed a pioneering approach to database design: using natural language queries to automatically generate formal data structures. This research aimed to bridge the gap between human-centric communication and the rigid technical requirements of database management systems.

The Challenge of Manual Design

Historically, creating a database schema required a human expert to translate real-world requirements into technical formats like the relational model. This process was often a significant bottleneck, as it required deep expertise in notations that were "foreign to the application domain." Lanka argued that instead of forcing designers to think in terms of tables and keys, they should be able to provide a "picture" of usage through natural language. By analyzing a set of queries the database is expected to answer, the system could synthesize the underlying schema automatically.

The Functional Data Model

Lanka’s system utilizes a functional data model rather than a traditional relational one. In this framework:

  • Entities (e.g., student, course) are treated as types.
  • Relationships are represented as functions (e.g., enroll(student) -> course).

This functional approach aligns well with the structure of natural language, where subjects and objects act as types and verbs act as functions connecting them.

From Syntax to Schema

The core mechanism of the system is a set of mapping rules that translate the syntactic components of a sentence—represented in a parse tree—into database structures.

A parse tree for the query "Which faculty teach a course in the CIS department?" used to extract schema components.

Key rules include:

  • Nouns to Entities: Common nouns that do not represent properties are identified as database types.
  • Prepositions to Properties: Prepositional phrases (e.g., "of a student") often signal specific properties of an object.
  • Verbs to Functions: The main verb typically denotes the relationship between entities. For instance, in the query "Which faculty teach a course?", the verb "teach" becomes a function mapping the faculty type to the course type.

Incremental Inference and Conflict Resolution

The system treats schema design as an incremental machine-learning problem. It processes queries sequentially, refining the schema with each new piece of information. Because natural language is inherently ambiguous, a single query might generate multiple "hypotheses" for the schema. The system manages this by maintaining disjoint unions of these hypotheses and seeking user feedback when conflicts—such as potential function overloading—cannot be resolved automatically.

Key Results

The paper provides a qualitative proof-of-concept using a university registrar domain. By processing a small set of queries—such as "Name the students enrolled for a course" and "Which faculty advise students?"—the system successfully synthesized a coherent schema.

The resulting database schema inferred from natural language queries, showing entities like Student, Faculty, and Course connected by functional relationships.

This demonstration showed that the "tedious and error-prone" task of manual schema definition could be replaced by an intuitive, query-driven process. The system could even infer hierarchies, such as identifying that a student is a subtype of person based on structural similarities in queries.

Limitations and Legacy

While groundbreaking, the approach faced several hurdles. The system's accuracy was entirely dependent on the quality of the natural language parser. Furthermore, while identifying the domain (input) of a function was straightforward, inferring the range (output type) often required additional heuristics. Finally, as the number of queries grew, the hypothesis space for potential schemas could become unmanageably large.

Despite these limitations, Lanka’s work established a vital insight: the way humans naturally ask questions about data contains the structural metadata needed to organize it. This "usage-as-definition" philosophy remains a core concept in modern efforts toward self-describing data and automated data engineering.

Summary updated

BibTeX
@inproceedings{lanka1985automatically,
  author = {Sitaram Lanka},
  title = {{Automatically Inferring Database Schemas}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1985},
}
Figure