NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Compiling Relational Database Schemata into Probabilistic Graphical Models

Sameer Singh, Thore GraepelarXiv 2012

TL;DR

This paper introduces a method to automatically "compile" existing relational database schemata into Bayesian graphical models. By treating table structures and foreign key relationships as blueprints for probabilistic dependencies, the authors enable automated machine learning tasks—like predicting missing values and performing complex relational queries—without requiring the user to be an expert in statistics.

The Problem: Bridging the Gap Between SQL and ML

Most of the world’s data resides in relational databases (SQL). While Probabilistic Graphical Models (PGMs) offer powerful tools for modeling such data, bridging the gap between a database schema and a functional model typically requires significant machine learning expertise.

Domain experts, such as doctors or accountants, understand their database schema—they know which tables link to which and what types of data are in each column—but they often lack the skills to manually specify the complex probabilistic dependencies needed for a PGM. This research aims to automate that process, turning the "latent" knowledge already encoded in a database schema into a functional generative model.

Methodology: Compiling Schemata into Models

The authors view a database schema as a "program" that describes how data is generated. Their compilation process follows two primary rules:

  1. Single Table Modeling: Each table is treated as a mixture model. Every row is assigned a latent (hidden) "component indicator." Depending on the data type of a column (real-valued, categorical, or Boolean), the model assigns a corresponding distribution (Gaussian, Discrete, or Bernoulli) to generate the data in that cell.
  2. Foreign Component Link: This is the "relational" core of the approach. Instead of treating tables in isolation, the model makes the hidden component of a row in Table B dependent on the hidden component of the row it points to in Table A via a foreign key. This is implemented using a mechanism called Gates to select appropriate distributions based on these links.
The compilation process: (a) shows a standard relational schema, and (b) shows the corresponding generated graphical model with latent components and dependencies.

For inference, the system utilizes Variational Message Passing (VMP) via the Infer.NET framework. This allows the model to handle "referential uncertainty," effectively predicting which foreign row a record should link to if that information is missing.

Experimental Evaluation

The researchers evaluated their approach on three distinct datasets:

  • Synthetic User-Movies-Ratings Data: Used to compare the relational model against a standard "flat" model (where tables are joined into one spreadsheet before modeling).
  • MovieLens 100k: A classic real-world dataset used to test how the model scales with 100,000 ratings.
  • Xbox Head-to-Head (TrueSkill): A dataset of match results used for qualitative analysis of entity clustering (e.g., grouping players by skill level).

Key Results and Insights

  • Relational vs. Flat Modeling: The authors demonstrate that "flattening" a database (performing a JOIN) before modeling loses crucial information. Their relational approach is significantly more robust when data is missing because it maintains the distinct identity and properties of related entities.
Comparison of prediction accuracy (RMSE) between a single table model and the relational model as the number of missing cells increases.
  • Accuracy and Scalability: On synthetic data, the schema-based model consistently outperformed the "join-then-model" approach in terms of Root Mean Square Error (RMSE), maintaining accuracy even when 50% of the data was missing. Furthermore, inference time scales linearly with the number of rows, making it viable for large-scale applications.
  • Automated Clustering: By using mixture models, the system automatically discovers "types" of entities. In the Xbox data, the model naturally grouped players into skill categories without explicit labels.

Limitations and Future Work

While promising, the current model requires users to specify the number of mixture components for each table. Future work may explore non-parametric models to learn cluster counts automatically. Additionally, the model currently assumes attribute independence within a row once the component is known; addressing correlations (e.g., City and Zip Code) through "cross-cutting models" is a suggested next step. Finally, the authors are interested in exploring alternative inference methods like Gibbs sampling to compare performance against VMP for complex schemata.

Summary updated

BibTeX
@misc{singh2012compiling,
  author = {Sameer Singh and Thore Graepel},
  title = {{Compiling Relational Database Schemata into Probabilistic Graphical Models}},
  year = {2012},
  eprint = {1212.0967},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1212.0967},
}
Figure