[ACCEPTED]-When to use MongoDB or other document oriented database systems?-mongodb

Accepted answer
Score: 666

In NoSQL: If Only It Was That Easy, the author writes about MongoDB:

MongoDB 41 is not a key/value store, it’s quite a bit 40 more. It’s definitely not a RDBMS either. I 39 haven’t used MongoDB in production, but 38 I have used it a little building a test 37 app and it is a very cool piece of kit. It 36 seems to be very performant and either has, or 35 will have soon, fault tolerance and auto-sharding 34 (aka it will scale). I think Mongo might 33 be the closest thing to a RDBMS replacement 32 that I’ve seen so far. It won’t work for 31 all data sets and access patterns, but it’s 30 built for your typical CRUD stuff. Storing 29 what is essentially a huge hash, and being 28 able to select on any of those keys, is 27 what most people use a relational database 26 for. If your DB is 3NF and you don’t do any joins (you’re just selecting a bunch of tables and putting all the objects together, AKA what most people do in a web app), MongoDB would probably kick ass for you.

Then, in the conclusion:

The real thing to point out is that if you are being held back from making something super awesome because you can’t choose a database, you are doing it wrong. If you know 25 mysql, just use it. Optimize when you actually 24 need to. Use it like a k/v store, use it 23 like a rdbms, but for god sake, build your 22 killer app! None of this will matter to 21 most apps. Facebook still uses MySQL, a 20 lot. Wikipedia uses MySQL, a lot. FriendFeed 19 uses MySQL, a lot. NoSQL is a great tool, but it’s certainly not going to be your competitive edge, it’s not going to make your app hot, and most of all, your users won’t care about any of this.

What am I going to build 18 my next app on? Probably Postgres. Will 17 I use NoSQL? Maybe. I might also use Hadoop 16 and Hive. I might keep everything in flat 15 files. Maybe I’ll start hacking on Maglev. I’ll use whatever is best for the job. If I need reporting, I won’t be using any NoSQL. If 14 I need caching, I’ll probably use Tokyo 13 Tyrant. If I need ACIDity, I won’t use NoSQL. If I need a ton of counters, I’ll 12 use Redis. If I need transactions, I’ll use Postgres. If I have a ton of a single type of documents, I’ll probably use Mongo. If I need to write 1 billion 11 objects a day, I’d probably use Voldemort. If 10 I need full text search, I’d probably use 9 Solr. If I need full text search of volatile 8 data, I’d probably use Sphinx.

I like this 7 article, I find it very informative, it 6 gives a good overview of the NoSQL landscape 5 and hype. But, and that's the most important 4 part, it really helps to ask yourself the 3 right questions when it comes to choose 2 between RDBMS and NoSQL. Worth the read 1 IMHO.

Alternate link to article

Score: 197

After two years using MongoDb for a social 4 app, I have witnessed what it really means 3 to live without a SQL RDBMS.

  1. You end up writing jobs to do things like joining data from different tables/collections, something that an RDBMS would do for you automatically.
  2. Your query capabilities with NoSQL are drastically crippled. MongoDb may be the closest thing to SQL but it is still extremely far behind. Trust me. SQL queries are super intuitive, flexible and powerful. MongoDb queries are not.
  3. MongoDb queries can retrieve data from only one collection and take advantage of only one index. And MongoDb is probably one of the most flexible NoSQL databases. In many scenarios, this means more round-trips to the server to find related records. And then you start de-normalizing data - which means background jobs.
  4. The fact that it is not a relational database means that you won't have (thought by some to be bad performing) foreign key constrains to ensure that your data is consistent. I assure you this is eventually going to create data inconsistencies in your database. Be prepared. Most likely you will start writing processes or checks to keep your database consistent, which will probably not perform better than letting the RDBMS do it for you.
  5. Forget about mature frameworks like hibernate.

I believe that 2 98% of all projects probably are way better 1 with a typical SQL RDBMS than with NoSQL.

Score: 27

to store this unstructured data

As you said, MongoDB 21 is best suitable to store unstructured data. And 20 this can organize your data into document 19 format. These RDBMS altenatives called NoSQL data 18 stores (MongoDB, CouchDB, Voldemort) are very useful for applications 17 that scales massively and require faster 16 data access from these big data stores.

And 15 the implementation of these databases are 14 simpler than the regular RDBMS. Since these 13 are simple key-valued or document style 12 binary objects directly serialized into 11 disk. These data stores don't enforce the 10 ACID properties, and any schemas. This doesn't provide any transaction abilities. So 9 this can scale big and we can achieve faster 8 access (both read and write).

But in contrast, RDBM 7 enforces ACID and schemas on datas. If you 6 wanted to work with structured data you 5 can go ahead with RDBM.

I would choose MySQL for 4 creating forums for this kind of stuff. Because 3 this is not going to scale big. And this 2 is a very simple (common) application which 1 has structured relations among the data.

Score: 13

Note that Mongo essentially stores JSON. If 17 your app is dealing with a lot of JS Objects 16 (with nesting) and you want to persist these 15 objects then there is a very strong argument 14 for using Mongo. It makes your DAL and 13 MVC layers ultra thin, because they are 12 not un-packaging all the JS object properties 11 and trying to force-fit them into a structure 10 (schema) that they don't naturally fit into.

We 9 have a system that has several complex JS 8 Objects at its heart, and we love Mongo 7 because we can persist everything really, really 6 easily. Our objects are also rather amorphous 5 and unstructured, and Mongo soaks up that 4 complication without blinking. We have 3 a custom reporting layer that deciphers 2 the amorphous data for human consumption, and 1 that wasn't that difficult to develop.

Score: 9

Who needs distributed, sharded forums? Maybe 28 Facebook, but unless you're creating a Facebook-competitor, just 27 use Mysql, Postgres or whatever you are 26 most comfortable with. If you want to try 25 MongoDB, ok, but don't expect it to do magic 24 for you. It'll have its quirks and general 23 nastiness, just as everything else, as I'm 22 sure you've already discovered if you really 21 have been working on it already.

Sure, MongoDB 20 may be hyped and seem easy on the surface, but 19 you'll run into problems which more mature 18 products have already overcome. Don't be 17 lured so easily, but rather wait until "nosql" matures, or 16 dies.

Personally, I think "nosql" will wither 15 and die from fragmentation, as there are 14 no set standards (almost by definition). So 13 I will not personally bet on it for any 12 long-term projects.

Only thing that can save 11 "nosql" in my book, is if it can integrate 10 into Ruby or similar languages seamlessly, and 9 make the language "persistent", almost without 8 any overhead in coding and design. That 7 may come to pass, but I'll wait until then, not 6 now, AND it needs to be more mature of course.

Btw, why 5 are you creating a forum from scratch? There 4 are tons of open source forums which can 3 be tweaked to fit most requirements, unless 2 you really are creating The Next Generation 1 of Forums (which I doubt).

Score: 7

I would say use an RDBMS if you need complex 4 transactions. Otherwise I would go with 3 MongoDB - more flexible to work with and 2 you know it can scale when you need to. (I'm 1 biased though - I work on the MongoDB project)

Score: 6

The 2 main reason why you might want to 3 prefer Mongo are

  • Flexibility in schema design (JSON type document store).
  • Scalability - Just add up nodes and it can scale horizontally quite well.

It is suitable for big data 2 applications. RDBMS is not good for big 1 data.

Score: 5

I've seen at lot of companies are using 11 MongoDB for realtime analytics from application 10 logs. Its schema-freeness really fits for 9 application logs, where record schema tends 8 to change time-to-time. Also, its Capped Collection feature 7 is useful because it automatically purges 6 old data to keep the data fit into the memory.

That 5 is one area I really think MongoDB fits 4 for, but MySQL/PostgreSQL is more recommended 3 in general. There're a lot of documentations 2 and developer resources on the web, as well 1 as their functionality and robustness.

Score: 3

You know, all this stuff about the joins 9 and the 'complex transactions' -- but it 8 was Monty himself who, many years ago, explained 7 away the "need" for COMMIT / ROLLBACK, saying 6 that 'all that is done in the logic classes 5 (and not the database) anyway' -- so it's 4 the same thing all over again. What is 3 needed is a dumb yet incredibly tidy and 2 fast data storage/retrieval engine, for 1 99% of what the web apps do.

Score: 1

Like said previously, you can choose between 11 a lot of choices, take a look at all those 10 choices: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis

What I suggest is to find your 9 best combination: MySQL + Memcache is really 8 great if you need ACID and you want to join 7 some tables MongoDB + Redis is perfect for 6 document store Neo4J is perfect for graph 5 database

What i do: I start with MySQl + Memcache 4 because I'm use to, then I start using others 3 database framework. In a single project, you 2 can combine MySQL and MongoDB for instance 1 !

More Related questions