Skip to main content
PreparationZone Logo
PrepZone

Graph Databases with Neo4j

Nodes, edges, and traversal queries for recommendations and fraud detection.

Pass checkpoint below

Why this matters

  • VaultCommerce recommendation and fraud teams ask relationship questions that explode in SQL: multi-hop paths, shared devices, circular referral chains.
  • Neo4j's Cypher query language expresses traversals in lines, not nested subqueries.
  • Graph stores are specialised — knowing when they earn their ops cost separates thoughtful architects from resume-driven design.
SQL (Postgres)
ACID transactions
Complex joins
Fixed schema
NoSQL
Flexible schema
Horizontal scale
Specialised access
Structured relations with joins favour SQL. Flexible schema and horizontal scale favour NoSQL.

Nodes, relationships, and properties

Graph primitives

  • Node — an entity with labels and properties (:User {id, email}).
  • Relationship — directed, typed edge (:PURCHASED, :REFERRED, :SHARES_DEVICE).
  • Traversal — walk edges to arbitrary depth with indexed start points.
  • Pattern matching — Cypher describes shapes, not join order.
Java
// Products co-purchased with items in the current cart
MATCH (u:User {id: $userId})-[:PURCHASED]->(p:Product)
MATCH (p)-[:BOUGHT_WITH]->(rec:Product)
WHERE NOT rec.id IN $cartProductIds
RETURN rec.id, rec.name, count(*) AS strength
ORDER BY strength DESC
LIMIT 8

VaultCommerce precomputes :BOUGHT_WITH edges nightly from order history so product pages serve recommendations in under 20 ms.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 3 sections

  • Recommendation vs relational joins
  • Fraud detection patterns
  • Syncing with the system of record

Test yourself

Answer these before moving on — recall is what makes it stick.