If you have recursive data (like in the Diaspora example), you should go with graph databases like Neo4j.
If you have data that is connected, that doesn't conform to a hierarchical model, you're looking for a Graph Database.
Take a look at the Diaspora example modeled as a Neo4j GraphGist.
Social Network Graph Example from Diaspora
This is a very "graphy" data structure. A commenter
is a user
, and a friend
is a user
, and a liker
is a user
.
A graph database simplifies this data structure to the following:
Which is easily queried using Cypher.
MATCH (u:User)-[:FRIEND]-(f)-[:POSTED]->(post)
WHERE u.name = "Rachel Green"
RETURN f.name AS friend, post.text AS content
When your data looks like this:
It's probably a good idea to go with a graph database.