Neo4j is a graph database. Regular databases store data in tables; graph databases store it as nodes and relationships. That sounds abstract until you see the use case: friends, recommendations, fraud detection, and anything where connections matter more than the data itself.
Imagine a social app. In SQL, finding "friends of friends" means joining tables several times and getting slow. In Neo4j, it is one query:
// Create two people and a friendship CREATE ( a : Person { name : "Aarav" } ) - [ : FRIENDS_WITH ] -> ( b : Person { name : "Meera" } )
// Find friends of friends MATCH ( me : Person { name : "Aarav" } ) - [ : FRIENDS_WITH * 2 ] -> ( fof : Person ) RETURN fof . name
Enter fullscreen mode
Exit fullscreen mode
That is the whole idea. Data looks like a diagram, and queries walk the diagram.β¦