Skip to main content

Relational Deep Learning: Learning from Relational Databases using GNNs

Relational Deep Learning (RDL) proposes a unified graph-based way to model multi-table databases for end-to-end learning using GNNs. This retains relational semantics, avoids joins, and supports temporal reasoning. It’s a paradigm shift that bridges the gap between ML and databases.


1. Motivation: From Tables to Graphs

Traditional Setup

Relational databases store structured data across multiple normalized tables, each capturing different types of entities (e.g., users, orders, products). These tables are linked by foreign-key (FK) and primary-key (PK) constraints.

To train machine learning models, these databases are typically flattened into a single table using joins, and domain experts manually select and engineer features.

Problems:

  • Joins are expensive and brittle (schema changes break pipelines).

  • Manual feature engineering is time-consuming and lacks relational awareness.

  • Loss of information about cross-entity relationships.


2. Core Idea: Learn Directly on the Schema

This paper proposes Relational Deep Learning (RDL) — a paradigm where:

  • The database is automatically transformed into a graph (called Relational Entity Graph).

  • A Graph Neural Network (GNN) learns over this graph end-to-end.

This means:

  • No need for manual joins or feature crafting.

  • You preserve multi-hop relationships (e.g., customer → transaction → product → vendor).

  • Dynamic predictions (e.g., churn, fraud) are enabled using temporal signals.


3. Relational Entity Graph (REG): The Foundation

How it's Built

Given a relational database:

  • Nodes = rows in tables (e.g., each customer, order, product is a node).

  • Edges = FK–PK links (e.g., order belongs to a customer).

This forms a heterogeneous graph:

  • Different node types: customers, products, transactions.

  • Different edge types: “purchased”, “reviewed”, etc.

Optional Additions

  • Node features: row attributes (e.g., age, price, date).

  • Timestamps: used for dynamic/temporal GNNs.

This graph retains relational and structural information that flat feature vectors would discard.


4. Deep Learning Pipeline

Relational Deep Learning solves predictive tasks on relational data with end-to-end learnable models. There are three main steps. (a) A database of relational tables is given. (b) A predictive task is specified and added to the database by introducing an additional training table. (c) relational data is transformed into its Relational Entity Graph, and a GNN trained on the training table. The task can be node level (as in this illustration), or link-level or higher-order.

Here’s how the full machine learning pipeline works:

(1) Task Definition

  • The user defines a training table with the target label(s).

  • This table typically links to the entities of interest (e.g., users for churn, transactions for fraud).

(2) Graph Construction

  • From the schema + keys, build the REG automatically.

(3) Feature Encoding

  • Convert raw database features into tensor representations:

    • Categorical → embeddings

    • Numeric → normalization

    • Timestamp → time-aware features

(4) Message Passing

  • Apply GNN layers (e.g., GraphSAGE, GAT) over the graph.

  • Each node updates its representation by aggregating messages from neighbors.

  • Enables multi-hop reasoning: a user's node learns from the behavior of purchased products, other users, etc.

(5) Prediction

  • Add MLP layers for classification/regression depending on the task.

  • Backpropagation updates all weights across message passing and embeddings.


5. Related Concepts AI Engineers Should Know

A. Relational Databases

  • Normalization: reduces redundancy; leads to many tables.

  • Foreign keys: links from one table to a related row in another.

  • Joins: SQL operations to combine data from multiple tables.

Ref:

B. Graph Neural Networks

  • Message-passing networks update each node's state by aggregating info from neighbors.

  • Key architectures:

    • GCN (Kipf & Welling): basic spectral approach

    • GraphSAGE: learns aggregators from neighborhood

    • GAT: uses attention over neighbors

Ref:

C. Temporal Graph Learning

  • Tasks where the time of interactions matters.

  • GNNs with time-aware components (e.g., TGAT, TGN) are used for:

    • Dynamic recommendation

    • Fraud detection

    • Churn prediction

Ref:


6. Benchmarks and Tools

The authors introduce RelBench, a benchmark suite of relational datasets + predictive tasks, including:

  • Stack Exchange QA threads

  • Amazon product reviews

  • Online retailers and clickstreams

They also provide:

  • Data conversion tools from SQL → REG graph

  • GNN training pipelines using PyTorch Geometric


References

Comments

Popular

How to Fine-Tune LLaMA 3.2-1B-Instruct for Korean Instruction Tasks with LoRA and Hugging Face

LLaMA 3.2-1B-Instruct is a lightweight instruction-tuned language model released by Meta. It is designed to handle a wide range of instruction-based tasks with relatively low computational resources. Although the model was trained with multilingual capabilities, its performance on languages not included in its training set—such as Korean—is limited. This tutorial demonstrates how to fine-tune this open-source model on a Korean dataset using Hugging Face Transformers and PEFT (specifically LoRA), enabling it to better respond to Korean instructions. 1. Prerequisites Before running the example code below, ensure you have the following libraries installed: pip install torch transformers datasets peft accelerate mlflow huggingface_hub To use the LLaMA model or KoAlpaca datasets, you'll need a Hugging Face token. Additionally, you may need to handle potential CUDA Out-Of-Memory (OOM) errors. The following code takes care of both: from huggingface_hub import login login("y...

RF-DETR: Overcoming the Limitations of DETR in Object Detection

RF-DETR (Region-Focused DETR), proposed in April 2025, is an advanced object detection architecture designed to overcome fundamental drawbacks of the original DETR (DEtection TRansformer) . In this technical article, we explore RF-DETR's contributions, architecture, and how it compares with both DETR and the improved model D-FINE . We also provide experimental benchmarks and discuss its real-world applicability. RF-DETR Architecture diagram for object detection Limitations of DETR DETR revolutionized object detection by leveraging the Transformer architecture, enabling end-to-end learning without anchor boxes or NMS (Non-Maximum Suppression). However, DETR has notable limitations: Slow convergence, requiring heavy data augmentation and long training schedules Degraded performance on low-resolution objects and complex scenes Lack of locality due to global self-attention mechanisms Key Innovations in RF-DETR RF-DETR intr...

SVD and Truncated SVD Explained: Theory, Python Examples, and Applications in Machine Learning & Deep Learning

Singular Value Decomposition (SVD) is a matrix factorization method widely used in mathematics, engineering, and economics. Since it's a crucial concept applied in accelerating matrix computations and data compression, it's worth studying at least once. SVD (Singular Value Decomposition) Theory Singular Value Decomposition (SVD) is a matrix factorization technique applicable to any real or complex matrix. Any matrix  A (m×n)  can be decomposed as follows: $A = U * \Sigma * V^T$ U : Orthogonal matrix composed of left singular vectors $(m \times m)$ Σ : Diagonal matrix $(m \times n)$ with singular values on the diagonal $V^T$ : Transposed matrix of right singular vectors $(n \times n)$ The singular values represent the energy or information content of matrix A, enabling tasks like dimensionality reduction or noise filtering. Truncated SVD Truncated SVD approximates the original matrix using only the top  k  singular values and corresponding singular vectors: $A \approx...