Reputation: 822
I just read this over at mongoid.org website (ODM for Ruby)
If you find that you have more relational associations in your application than embedded ones, it is recommended that you not use MongoDB and move to a relational database.
Is this a valid statement?
Upvotes: 2
Views: 2596
Reputation: 46281
Is this a valid statement?
I don't think so. I believe that over-embedding and avoiding relations are two of the most common beginner's mistakes with MongoDB. More importantly it doesn't matter so much how the data is structured. What matters is what you need to query, and whether you know that in advance.
Relational databases are good at wild combinations of query constraints over different tables: "What have customers who live in cities where we operate most stores bought on days where the sun shone?" An SQL database can answer that question well. With the right indexes, you can make entire classes of these queries fast. That is particularly useful if you don't know the questions that will be asked 'at compile time', so to speak.
Unfortunately, that comes at the cost of complexity: Depending on what questions you ask, the results have different structure, but your typical LOB application mostly needs to fetch objects and store them back. Also, creating SQL queries isn't trivial, so you'll either have to write them by hand or use a complex piece of software, an object-relational-mapper, that creates the queries, assembles the objects and stitches everything back together. Avoiding that monstrous piece of software and complexity, is a key reason to use MongoDB from my point of view. Hence, the idea of object-document-mappers generally sounds fishy to me.
The discussion of locks, transactions, 'scale', etc. is largely orthogonal.
If you know your queries in advance, MongoDB can cope with relations relatively well, and you can avoid most transactions. If you need business intelligence queries, you're probably better off with a relational DB.
Upvotes: 4
Reputation: 482
MongoDB is a document oriented database. Transactions and relation are not featured in this solution. It gives a more scalable environment despite of this limitation.
You should go to mongodb.org to have more information to this solution.
Upvotes: 0