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

SQL for SRL: Structure Learning Inside a Database System

Oliver Schulte, Zhensong QianarXiv 2015

Abstract

Statistical Relational Learning (SRL) typically involves extracting data from relational databases into external tools, creating significant performance bottlenecks. This paper introduces FACTORBASE, a system that integrates SRL directly into a Relational Database Management System (RDBMS). By treating statistical models as first-class citizens and leveraging SQL for complex join and aggregate operations, FACTORBASE achieves order-of-magnitude improvements in scalability and prediction speed, handling datasets with millions of records.

Introduction

Traditional machine learning algorithms often assume data is stored in a single flat table. However, real-world data is inherently relational, distributed across multiple tables with complex interdependencies. Statistical Relational Learning (SRL) addresses this by modeling these relationships. A major hurdle in SRL is the computational cost of learning these models, often requiring the extraction of massive amounts of data to external processing environments. FACTORBASE proposes a paradigm shift: instead of moving data to the model, the model should be built where the data resides—inside the database.

System Architecture

FACTORBASE utilizes SQL as a high-level scripting language to manage the entire learning pipeline. The architecture is divided into three primary components that transform raw data into a structured statistical model.

The FACTORBASE pipeline: from input database to model database via intermediate metadata and count databases.
  1. Schema Analyzer (Variable Manager): This component scans the database catalog to identify relational random variables. These are stored in a Variable Database (VDB), providing an editable metadata layer for the model's scope.
  2. Count Manager: This core engine performs the heavy lifting by calculating "sufficient statistics"—counts of patterns across tables—using standard SQL JOIN, SUM, and COUNT operations. These statistics are cached in a Count Database (CDB) to optimize the model structure search.
  3. Model Manager: Leveraging the counts in the CDB, this component learns the structure of a Bayesian Network (e.g., using the "learn-and-join" algorithm). The final structure and parameters are stored in a Model Database (MDB).

Performance and Scalability

The system was evaluated using six benchmark databases, scaled to over $10^6$ records. This represents a significant advancement over previous state-of-the-art systems, which typically reached their limits at $10^5$ records.

Key findings include:

  • Efficiency in Counting: The primary bottleneck in SRL is cross-table counting. By using RDBMS engines, FACTORBASE efficiently manages up to 15 million sufficient statistics.
  • Set-Based Prediction: By implementing "block prediction" via SQL joins rather than iterative row-by-row processing, the system achieves a 10x to 100x speedup in model inference.
  • Complex Correlation Discovery: The ability to process larger volumes of statistics allows the discovery of more intricate correlations across tables that were previously computationally inaccessible.

Conclusion and Future Work

FACTORBASE demonstrates that relational algebra (SQL) is a powerful language for computing structured statistical objects, analogous to how linear algebra serves deep learning. While currently focused on Bayesian Networks via the "learn-and-join" algorithm, future work aims to generalize this architecture to other SRL frameworks like Relational Dependency Networks. Additionally, FACTORBASE could serve as a high-performance backend for probabilistic logic languages, acting as a compiler that translates high-level specifications into optimized SQL.

Summary updated

BibTeX
@misc{schulte2015sql,
  author = {Oliver Schulte and Zhensong Qian},
  title = {{SQL for SRL: Structure Learning Inside a Database System}},
  year = {2015},
  eprint = {1507.00646},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1507.00646},
}
Figure