Relational Schema to Heterogeneous Graph¶
Run the Relational Schema to Heterogeneous Graph MicroSim Fullscreen
Edit in the p5.js Editor
About This MicroSim¶
Relational databases store entities in tables and relationships as foreign keys. Relational Deep Learning (RDL) converts this relational structure directly into a heterogeneous graph: each table row becomes a node of the table's type, and each foreign-key link becomes a typed edge.
This MicroSim shows three tables side by side (Customers, Orders, Products). Click any row to highlight the corresponding node in the graph panel on the right and draw its edges. Hovering over an edge shows which columns produced it.
Learning objective (Bloom's Understand (Level 2)): See how foreign keys in a relational database (Customers, Orders, Products) map to typed nodes and typed edges in a heterogeneous graph, making the schema-to-graph transformation concrete.
How to Use¶
- Read the tables — Customers, Orders, and Products tables are shown at the top.
- Click a table row — the corresponding node in the graph lights up and its edges are highlighted.
- Click a graph node — the corresponding table row lights up.
- Hover an edge — see which foreign-key column created this edge and what information flows along it.
- Schema key — the color-coded key on the right maps each table to its node color.
Iframe Embed Code¶
You can embed this MicroSim in any web page with the following HTML:
<iframe src="https://AnvithPothula.github.io/graph-neural-networks-textbook/sims/ch17-table-to-graph/main.html"
height="562"
width="100%"
scrolling="no"></iframe>
Lesson Plan¶
Grade Level¶
Undergraduate / Graduate (College Level)
Duration¶
10–15 minutes
Prerequisites¶
Relational database basics (primary key, foreign key). Heterogeneous graphs (Chapter 15).
Activities¶
- Identify all edges in the graph that correspond to the "customer_id" foreign key in the Orders table.
- Add a new row to the Orders table (mentally). How many new nodes and edges would appear in the graph?
- The Product→Order edge represents "appears in". What does a product node's neighborhood encode about buying patterns?
Assessment Question¶
Define the schema graph for the Customers–Orders–Products database. For each table, state its node type and the features that would be encoded on each node. List all edge types and their directions.
References¶
- Fey et al. (2023). Relational Deep Learning: Graph Representation Learning on Relational Databases. NeurIPS 2024.
- Cvitkovic (2020). Supervised Learning on Relational Databases with Graph Neural Networks.
Part of Chapter 17: Relational Deep Learning. Return to the chapter page or browse all MicroSims.