Neo4j: When Relationships Are the Data, Not the Detail

Neo4j isn't a replacement for SQL — it's a fundamentally different tool. It excels where relationships between entities are the critical data: social networks, fraud detection, recommendation engines, enterprise knowledge graphs. This guide walks you through the property graph model, your first Cypher queries, and how to get started for free with AuraDB Free in under three minutes.

Share

Tempo di lettura: 6 minuti

Neo4j is the world’s most widely used graph database — and its difference from SQL comes down to one idea: relationships aren’t a side effect of the data model, they’re the core of it. Fraud detection, social networks, supply chains, recommendation engines: all domains where the connections between entities matter more than the entities themselves. This guide covers the property graph model, the Cypher query language, and how to get started for free with AuraDB Free in under three minutes. Third installment of the Digital Stack 2026 series.

Picture needing to find all friends-of-friends of a user in a SQL database. You write a query with two JOINs. Then you realize another level of depth needs a third JOIN. And answering the question “what’s the shortest path between these two users”? Forget it — the query becomes unreadable before it works, and performance drops with every additional depth level.

This isn’t an optimization problem. It’s structural: SQL was designed for tables and rows, not networks and connections. When the relationship between data is the most important data, a graph database isn’t an exotic alternative. It’s the obvious choice.

The Property Graph Model: Nodes, Relationships, Properties

A graph database represents the world in three elements. Nodes are entities — a person, a movie, a product, a bank account. Relationships are typed, directional connections between nodes — with a name and a direction: ACTED_IN, FOLLOWS, PURCHASED. Properties are attributes assignable to both nodes and relationships: name, date, weight, transaction duration.

The technical difference from SQL is fundamental. In SQL, a relationship between entities is a column value (a foreign key) — finding all connected records requires a JOIN traversing separate tables, with costs that grow exponentially with depth. In Neo4j, a relationship is a first-class graph element with direct physical pointers: traversing it requires no join at all, it’s a direct O(1) read per hop. Performance doesn’t degrade with graph complexity.



The Query That Explains Everything: MATCH in Action

The image below shows the query MATCH (p:Person)-[r:ACTED_IN]->(m:Movie) RETURN p, r, m LIMIT 20 running on AuraDB’s Movie dataset. The result isn’t a table: it’s an interactive visual graph. Beige nodes represent Person entities (Al Pacino, Charlize Theron, Keanu Reeves and others), green nodes represent Movie entities (The Matrix, The Devil’s Advocate, A Few Good Men). Directed ACTED_IN arrows connect each actor to the films they appeared in.

The central node — Keanu Reeves, selected with a cyan border — surfaces his properties in the right panel: born 1964, full name. One line of Cypher delivers what SQL would need two tables, a JOIN, and a WHERE clause to produce — in 237 milliseconds on a cloud database. Click any node and you see its properties instantly, without writing another query.

Neo4j Browser graph: MATCH Person ACTED_IN Movie, Keanu Reeves node selected (born 1964) connected to The Matrix
One Cypher query, one interactive graph: every node is clickable and surfaces its properties in real time

AuraDB Free: Start Without Installing Anything

Neo4j has a well-earned reputation as powerful but complex to set up. AuraDB Free dismantles that perception entirely. It’s Neo4j Inc.’s permanently free cloud tier: no credit card, no Docker, no Java installation required. Go to console.neo4j.io, sign in with Google, click Create instance, choose AuraDB Free. Your instance is ready in under two minutes.

The image below shows exactly what you find after creation: an instance with RUNNING status (green dot), a unique ID, type AuraDB Free, and counters already updated — 70 nodes and 179 relationships from the preloaded sample dataset. The Open button gives direct access to Query (Cypher editor in the browser), Explore (drag-and-drop graph visualization, no code required), Dashboards, and Developer Hub. A complete Neo4j environment, free, accessible from any browser.

Neo4j AuraDB console: Free instance RUNNING, 70 nodes and 179 relationships, Open menu showing Query and Explore
AuraDB Free is live in two minutes: zero installations, direct browser access, no credit card required


Cypher: the Language That Speaks in Patterns

Cypher is Neo4j’s query language. Its syntax is designed to visually resemble a graph: nodes in parentheses (n:Label), relationships as arrows in square brackets -[r:TYPE]->. If you can read an ER diagram, learning Cypher takes an afternoon. The core command is MATCH — the equivalent of SELECT FROM JOIN in SQL, without needing to declare the tables to join:

MATCH (a:User)-[:FOLLOWS]->(b:User)
RETURN a.name, b.name

This query finds all users who follow other users. No join table to declare, no foreign key to specify. The relationship type :FOLLOWS is enough to traverse the graph.

Friends of Friends: the Query SQL Can’t Handle Well

Finding users reachable at two degrees of separation via FOLLOWS takes one line: MATCH (a:User)-[:FOLLOWS*2]->(b) RETURN b. The asterisk specifies traversal depth — *3 for three degrees, *1..5 for any depth between one and five. The SQL equivalent would require at least three nested JOINs, with performance collapsing on real-world dataset sizes.

The image below shows a real result on a social dataset containing hundreds of users: 210 User nodes found in just 19 milliseconds. The right panel shows the properties of one reached user — Sam Wilson, game developer in Milan, 1,950 followers, joined November 2019. Real data, real relationships, real-world speed on AuraDB Free cloud.

Neo4j graph query FOLLOWS*2 returns 210 nodes in 19ms, Sam Wilson user node: Milan, game developer, 1950 followers
210 users reached at 2 degrees of separation in 19 milliseconds: this is native graph database speed


Shortest Path: Finding Hidden Connections

This is where Neo4j definitively separates itself from SQL — and from MongoDB. The shortestPath() function calculates the shortest path between any two nodes in the graph, natively and optimally. You don’t implement Dijkstra yourself: you call it directly in Cypher. The image below shows the complete query on the social dataset — finding the shortest path between peter_junior and nick_startup through the FOLLOWS network, extracting usernames, degrees of separation, and real names of every node in the chain:

MATCH (peter:User {username: 'peter_junior'}),
      (nick:User {username: 'nick_startup'}),
      path = shortestPath((peter)-[:FOLLOWS*..]-(nick))
RETURN [node IN nodes(path) | node.username] AS connectionPath,
       LENGTH(path) AS degrees,
       [node IN nodes(path) | node.name] AS names

The table result is precise: Peter Parker and Nick Fury don’t follow each other directly, but the shortest path between them passes through Alice Johnson (alice_tech) and Bob Smith (bob_data) — exactly three degrees of separation. Notice the Browser message: the results can’t be visualized as a graph because the query returns extracted value lists, not node structures. Neo4j knows when to use a table.

Cypher shortestPath query result: 3-degree path peter_junior to nick_startup via alice_tech and bob_data, tabular output
shortestPath() in Cypher: 3 degrees of separation between Peter Parker and Nick Fury, exact path returned as a table

When to Use Neo4j (and When Not To)

Neo4j excels when relationships are the critical data. Classic use cases: fraud detection (anomalous patterns between accounts and transactions — multiple financial institutions use graph databases to identify coordinated fraud networks), social networks (followers, community detection, personalized feeds), recommendation engines (who bought X also bought Y), enterprise knowledge graphs (who knows whom, who worked on what), supply chain (tracing a component’s provenance through multiple supplier tiers).

It’s not the optimal choice for simple aggregate queries on high-volume flat data, for OLAP workloads on tabular datasets, or for domains where entities have very few relationships with each other. In those cases, PostgreSQL performs better with less operational overhead.

Neo4j vs MongoDB vs SQL: a Quick Compass

MongoDB with $graphLookup allows navigating graph structures — but without Neo4j’s integrated algorithm libraries (Graph Data Science: shortest path, PageRank, community detection, centrality) and with performance that degrades on deep or large graphs. For simple graph traversal with heterogeneous data, MongoDB is a reasonable option. For advanced graph algorithms, Neo4j is the correct choice. SQL remains unbeatable for ACID transactions, aggregate queries, and inherently tabular data. The good news: in real-world architectures, all three coexist — something we’ll explore fully in the polyglot persistence article later in this series.

Up Next: Claude Code and Claude Design

Three building blocks of the Digital Stack 2026 series are now in place: Google Forms for structured data collection, Google Sheets for analysis with pivot tables and formulas, Neo4j for complex relationship data. Next week we step away from databases entirely and look at the future of development tools: Claude Code and Claude Design, the two Anthropic products launched in April 2026 that are reshaping how digital products are built and presented — from idea to working code, without opening an IDE. Graph databases with Neo4j: a concrete new tool in your stack. Now it’s time to build something with it.

More To Explore

Artificial intelligence

Sentiment Analysis & Topic Modeling: What Your Customers Really Mean

You have 200 reviews, 500 support tickets, 1,000 social media comments. Reading them all would take days — and you’d still miss the most important patterns. Sentiment Analysis and Topic Modeling solve exactly this: in ten minutes you get the emotional tone of every text, recurring themes grouped automatically, and a strategic summary that manual reading would never have produced.

Artificial intelligence

Multimodal AI: Analyze PDFs, Images and Documents with Claude, GPT-4 and Gemini

AI no longer reads only text. Claude summarizes a 10-page quote in 30 seconds. GPT-4 Vision transcribes data from a dashboard screenshot into a ready-to-use table. Gemini 1.5 Pro navigates 1,000-page documents citing the sources. This guide shows how they work, when to use which tool, and where the time savings are measurable — with real screenshots from live sessions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Progetta con MongoDB!!!

Acquista il nuovo libro che ti aiuterà a usare correttamente MongoDB per le tue applicazioni. Disponibile ora su Amazon!