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

Building an MCP Agent with UV, Python & mcp-use

Model Context Protocol (MCP) is an open protocol designed to enable AI agents to interact with external tools and data in a standardized way. MCP is composed of three components: server , client , and host . MCP host The MCP host acts as the interface between the user and the agent   (such as Claude Desktop or IDE) and plays the role of connecting to external tools or data through MCP clients and servers. Previously, Anthropic’s Claude Desktop was introduced as a host, but it required a separate desktop app, license, and API key management, leading to dependency on the Claude ecosystem.   mcp-use is an open-source Python/Node package that connects LangChain LLMs (e.g., GPT-4, Claude, Groq) to MCP servers in just six lines of code, eliminating dependencies and supporting multi-server and multi-model setups. MCP Client The MCP client manages the MCP protocol within the host and is responsible for connecting to MCP servers that provide the necessary functions for the ...

How to Save and Retrieve a Vector Database using LangChain, FAISS, and Gemini Embeddings

How to Save and Retrieve a Vector Database using LangChain, FAISS, and Gemini Embeddings Efficient storage and retrieval of vector databases is foundational for building intelligent retrieval-augmented generation (RAG) systems using large language models (LLMs). In this guide, we’ll walk through a professional-grade Python implementation that utilizes LangChain with FAISS and Google Gemini Embeddings to store document embeddings and retrieve similar information. This setup is highly suitable for advanced machine learning (ML) and deep learning (DL) engineers who work with semantic search and retrieval pipelines. Why Vector Databases Matter in LLM Applications Traditional keyword-based search systems fall short when it comes to understanding semantic meaning. Vector databases store high-dimensional embeddings of text data, allowing for approximate nearest-neighbor (ANN) searches based on semantic similarity. These capabilities are critical in applications like: Question Ans...

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...