</> MAANG.io
system design · 201

Intermediate

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/124 solved 0% complete

Neo4j (Graph Database)

maang.io System Design Series


Neo4j stores data as a property graph — nodes and relationships as first-class citizens. Its key trick is index-free adjacency: relationships are direct pointers, so traversing them is O(1) per hop instead of a JOIN. That makes deep, connected queries (recommendations, fraud rings, social graphs) fast where relational databases choke, all expressed in the Cypher query language.

This deep dive comes in three parts:

  • Foundations & Core Concepts — the property-graph model, index-free adjacency, and Cypher.
  • Internals — the record store, linked-list traversal, and where graphs win, with worked numbers.
  • Interview — Staff/Principal Q&A: graph-vs-relational and modeling connected data.

Neo4j (Graph Database) — Part 2: Internals & Index-Free Adjacency

maang.io System Design Series


What is this?

Back to our town of houses and bridges. In Part 1 we said the magic was the rack of keys by each front door — you walk straight to a neighbour instead of phoning the town hall. This chapter is where we open the door and look at how those keys are actually cut, stored, and followed. It turns out the whole trick reduces to one beautifully boring idea: store everything as fixed-size records, so finding record number N is just multiplication. No index, no search — arithmetic.

That idea has a name — index-free adjacency — and by the end of this chapter you'll be able to explain, at the byte level, why a hop across the graph costs O(1) and why that's fundamentally different from a JOIN.

The one-line idea: Neo4j lays nodes, relationships, and properties into separate store files as fixed-size records. Because every record is the same size, record N lives at byte offset N × recordSize — an O(1) address computation. Relationships are stored as doubly-linked lists threaded through both of their endpoint nodes, so "walk to the next neighbour" is follow a pointer, jump to that offset — never an index descent, never a join.

Let's build the storage engine from the bottom up, then trace a read and a write through it.


Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.