DATA ARCHITECTUREGraphs

Graph Data Modeling

How data engineers design data that lasts — pick a topic on the left and its full breakdown loads here: the mental model, ERDs and worked schemas, trade-offs, edge cases, and the decisions that separate a durable model from a fragile one.

18 min readTopics chapter readerLevel · Specialized & Applied
01 · Orientation

What You'll Master Here

A graph stores entities as nodes and their relationships as first-class typed, directed, attributed edges, so you walk connections instead of joining tables.

4 min · Topic 1 of 8

Most databases treat a relationship as something you reconstruct: a foreign key, a join table, a join computed at query time. A graph database stores it instead, as a typed, directed object that can carry facts of its own. This chapter is about modelling a domain when the connections between things are the point.

One domain runs through every topic: Kestrel, an open-source package registry where packages depend on packages, maintainers maintain them, and advisories affect version ranges. Start with the map below. It shows the graph and the six decisions that produced it, and each decision links to the topic that makes it.

Core mental model

A graph stores entities as nodes and their relationships as first-class typed, directed, attributed edges, so you walk connections instead of joining tables.

Why it matters

Recommendations, fraud rings, dependency and supply-chain analysis, knowledge graphs and network topology are all questions about paths. Knowing when that shape justifies a graph store, and when it does not, is a senior architecture judgment.

node
An entity in the graph, with a label (its type) and properties.
relationship
A typed, directed edge between two nodes, which can carry its own properties.
traversal
Walking from node to node along relationships to answer a question.
hop
One step along a relationship from one node to the next.
The Kestrel package registry14 packages, 31 DEPENDS_ON edges. Every widget in this chapter runs on this one graph.checkout-api is the application at the top. Everything below it is something checkout-api ships, directly or transitively. Notice how hard the tiers converge: four frameworks, six utilities, three base libraries.
  • applicationcheckout-api
  • frameworkshttp-kitauthgatequeue-riderledger-sdk
  • utilitiesjson-liteuri-parselogsigmetrics-tapcryptoboxrandseed
  • base librariesbytebuftinyparseclockshim
Six decisions turned that domain into this graph
Common mistake

Reaching for a graph because one query in the system is a traversal. You take on a second database, a second copy of the data, and a sync problem, to speed up a query a recursive CTE already answered.

Better habit

Ask whether the hard questions are about paths or about totals before choosing a store.

Model relationships as first-class edges, not join tables.

Keep aggregation-heavy analytics in relational or dimensional stores.

The big idea

In a graph, a relationship is data you store and walk, not a join you compute. That is what makes deep and variable-length questions both natural to express and cheap to run.

Remember this

Graph databases make relationships first-class so connected, multi-hop questions become traversals; use them when the connections are the point, not for tabular aggregation.