On Embeddings in Relational Databases

Siddhant Arora, Srikanta BedathurarXiv 2020

Abstract

We address the problem of learning a distributed representation of entities in a relational database using a low-dimensional embedding. Low-dimensional embeddings aim to encapsulate a concise vector representation for an underlying dataset with minimum loss of information. Embeddings across entities in a relational database have been less explored due to the intricate data relations and representation complexity involved. Relational databases are an inter-weaved collection of relations that not only model relationships between entities but also record complex domain-specific quantitative and temporal attributes of data defining complex relationships among entities. Recent methods for learning an embedding constitute of a naive approach to consider complete denormalization of the database by materializing the full join of all tables and representing as a knowledge graph. This popular approach has certain limitations as it fails to capture the inter-row relationships and additional semantics encoded in the relational databases. In this paper we demonstrate; a better methodology for learning representations by exploiting the underlying semantics of columns in a table while using the relation joins and the latent inter-row relationships. Empirical results over a real-world database with evaluations on similarity join and table completion tasks support our proposition.

Introduction

Relational databases (RDBs) are the backbone of modern data storage, yet they are notoriously difficult to represent in the continuous vector spaces required by deep learning. Unlike a sequence of text, a database is a complex web of tables, joins, and specific attribute types. Existing approaches usually take one of two paths: they either "denormalize" the database into one giant table and treat each row as a sentence for Word2Vec, or they convert the database into a Knowledge Graph (KG). Both have flaws. Word2Vec ignores the fact that some columns (like a movie's rank) are more important than others, and KG methods often fail to capture "latent" relationships—like the fact that two directors are similar because they followed similar career trajectories over time.

Methodology

We propose two primary enhancements to standard embedding techniques to better capture the inherent structure of relational data.

Column Semantics via Weighted Sampling

Instead of treating every item in a row equally, we use continuous-valued attributes to guide the training process. For example, in Genre Sampling, if a director has a high probability of directing "Horror," that genre is sampled more frequently in the "sentences" used to train the Word2Vec model. This forces the model to learn that the director is more closely tied to their primary genres.

Incorporating Inter-row Relationships with LSTMs

To capture how entities evolve, we treat a sequence of related rows as a time series. We use an LSTM to process a director’s career—movie by movie—concatenating features like actors, genres, and release years into a single "movie embedding" at each time step. This allows the model to predict the next movie in a sequence, creating a "time-sensitive" embedding for the director.

The LSTM architecture used to generate director embeddings based on a temporal sequence of movie features.

Context Window Optimization

In NLP, words far apart in a sentence are usually less related. In a database row, every cell is equally related to every other cell in that row. We found that the Word2Vec context window should span the entire row to be effective, ensuring all intra-row dependencies are captured.

Experimental Setup

The study uses the IMDB movie database, a classic relational dataset consisting of 7 tables and 21 columns (including directors, movies, actors, genres, and ranks). To evaluate the quality of the resulting embeddings, we used the Milne-Witten Inlink Score from Wikipedia as a "gold standard" for semantic relatedness between directors.

Key Results

The researchers evaluated their models on two tasks: Similarity Queries (finding similar directors) and Table Completion (predicting missing values in a joined table).

  • Similarity: The "Genre w2v" model significantly outperformed the Knowledge Graph baseline (TransH) and the basic Word2Vec model. It achieved a Prec@10 of 0.196, compared to just 0.106 for TransH.
  • Table Completion: The sampling-based models were highly effective at predicting missing data cells, reaching a precision of nearly 0.8 at Prec@20.
  • Time-Specific Tasks: For predicting future events in the database, the LSTM variants (specifically those using "Popular Actor" sampling) were the clear winners, achieving roughly 0.6 Precision@20.
Graphs showing the precision of different models on random and time-specific table completion tasks.

Conclusion

The primary limitation is that the evaluation is focused on a single (though complex) dataset: IMDB. Additionally, using Wikipedia's link structure as a "gold standard" for similarity might bias the results toward more famous entities. Future work should look into more formal, declarative ways to share these data semantics with machine learning frameworks, potentially creating a more automated pipeline for embedding any relational database regardless of its domain.

Summary updated

BibTeX
@misc{arora2020embeddings,
  author = {Siddhant Arora and Srikanta Bedathur},
  title = {{On Embeddings in Relational Databases}},
  year = {2020},
  eprint = {2005.06437},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2005.06437},
}
Figure