1

EDIT: I edited the question and separated the "MongoDB: Replicate data in documents vs. "join"" part into this topic on https://softwareengineering.stackexchange.com/

I have already played a bit with the mongoDB aggregation framework building some dummy queries and seeing the potential of the pipelining, the sub-documents structures in order to avoid the traditional SQL JOINs and so on.

Also, I've already read about when to use a document-oriented data base, checked out some MongoDB production deployments and use cases examples, and realized that the Oracle nested tables isn't a real alternative in terms of performance vs MongoDB.

I've also checked out the Diaspora MongoDB use case, in which they explains about the recursive data problem, an evidence that the graph data bases would fit better for that kind of scenarios: enter image description here

Finally, and in order to structure all of these information in my used-to-be-normalized-head, I want to know what do you think about the following conclusions:

  1. If you have recursive data (like in the Diaspora example), you should go with graph databases like neo4j.
  2. Replicate data in each document vs. "join" example: Question separated into this one.

Thanks!

Community
  • 1
  • 1
JavierCane
  • 2,324
  • 2
  • 22
  • 19
  • I would strongly suggest that you reconsider this as various questions that you want to ask here and not as one. And also consider it likely that you will learn something from each question in turn. But as is this just offers a broad discussion and way to much for a single answer. Try [programmers.stackexchange.com](http://programmers.stackexchange.com) which is better suited to discussion like this. – Neil Lunn Apr 30 '14 at 02:30
  • Thanks for your recommendation Neil. I have done it just now: http://programmers.stackexchange.com/questions/237469/mongodb-replicate-data-in-documents-vs-join – JavierCane Apr 30 '14 at 07:10

1 Answers1

4

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

Diaspora Data Model

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:

Diaspora Graph Data Model

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:

Neo4j GraphGist Data Model

It's probably a good idea to go with a graph database.

Kenny Bastani
  • 3,268
  • 15
  • 20
  • I completely agree with that, thanks for your comment Kenny. I really appreciate your contribution, but I can't choose your answer as the accepted one because I'm also asking about which would be "the limit" of the document-oriented databases such as MongoDB. I mean: When a document-oriented database exactly fits your needs taking into account possible application's requirements changes as the stated in the question 3th point "Replicate data in each document vs. "join" example:"? – JavierCane Apr 29 '14 at 20:10
  • 1
    I think you're asking a lot in a single Stack Overflow post. Maybe chunk it up into a few different questions to make it easier to answer. I've provided the perspective from the Graph Database side of things. – Kenny Bastani Apr 29 '14 at 20:13
  • You're right. I have tried to provide as much information as I could, but that makes the question unclear and unfocused from the important thing (the example of the third point). Thanks for your advice, maybe it's too late to separate it into different questions because perhaps the doubt is clearer now. – JavierCane Apr 29 '14 at 20:33
  • I don't think it's too late. If you leave it as is (3 independent assertions), I think you'll find it getting closed since there's no way to objectively answer with a single answer (especially if people start disagreeing about the individual answers). – David Makogon Apr 30 '14 at 00:41
  • I just separated the question into this one: http://programmers.stackexchange.com/questions/237469/mongodb-replicate-data-in-documents-vs-join Thanks again for your answer Kenny, I learned a lot thanks to it (I didn't know about the GraphGist tool and it's amazing :D ) – JavierCane Apr 30 '14 at 07:14