6

I develop 3 to 4 Spring Roo applications a year currently with Hibernate and MySQL. It has been stated here at Stackoverflow that relational databases are not the best fit for a typical object oriented webapplication .

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.

There are various reasons for this. One is productivity as objects are mapped to a relational schema ("joins" etc.). Would the use of MongoDB or CouchDB increase development productivity given the same level of expertise as with MySQL?

5
  • 1
    Why are relational databases not good for web apps? If you make that app a desktop app does it suddenly make it okay?
    – duffymo
    Sep 23, 2011 at 10:03
  • I agree with Dave's comments above. I am not sure what you exactly mean by productivity above. Does that mean being able to develop the application quicker, or are you talking about performance? Sep 23, 2011 at 10:22
  • productivity is never performance, but I will edit and clarify. By Web app I mean the typical java stack for webapps, will clarify too Sep 23, 2011 at 11:31
  • I would love to see the SO post which stated that the NoSQL databases are the best fit for the java web application stacks.
    – bhagyas
    Sep 23, 2011 at 11:37
  • bhagyas you are served with a citation Sep 23, 2011 at 11:49

1 Answer 1

7

I think it really depends on the web application. Non-relational databases (NoSQL) excel where you either

  • Don't want a schema (want to be able to store different sorts of data in the same table), and/or
  • Don't have too complex of relation between objects.

NoSQL can definitely make it easier to get off the ground faster, because you can just throw stuff in however you want, but on the downside as things get more complex sometimes you want a little more forced organization. Foreign keys are something I really miss when working with Mongo, just being able to (using an ORM) hop from one object to a related one or set of them is great. (Yes in many NoSQL dbs you can store documents, but at some point you need to use a separate table for something.)

I would highly recommend NoSQL for a brochure style website, where the client is just entering text fields, or a twitter-style site, where largely you are storing lots of one type of data with few attributes. But if you're going to be creating a CMS with revisions and workflow and such, you're going to want the ability to have explicit relations in SQL.

Which brings me to my answer: use the right tool for the job. A trained developer would be able to make some sites faster and better with SQL, and other sites faster and better with a non-relational database.

But try out MongoDB or CouchDB and get a feel for it, that way you'll have a better intuition on when to use what. (We use both at my job (not at the same time!) depending on the project)

4
  • Since Spring Roo creates my Schema automagically during early development, do you think there is still a productivity benefit with MongoDB? Sep 23, 2011 at 11:38
  • +1 although document relations shouldn't really be compared with RDBMS relations.
    – jgauffin
    Sep 23, 2011 at 11:48
  • I don't think there is a productivity benefit at all. SQL and NoSQL are completely different approaches and lead you to a completely diffent software architecture. Comparing two "architectures" regarding productivity is only possible if the same person/team writes the same application twice using both approaches AND forgetting anything learned by doing the first time. In other words if you tell any manager: "lets do it NoSQL" because then we will be faster, is complete nonsense. Sep 23, 2011 at 12:23
  • Also: it has absolutely nothing to do weather your Application is a web application, a distributed application or a monolithic desktop application. The only things that matter are the ACID/consistency requirements, the replication, the speed of writing and reading and amount of data to store, failover safety etc. Sep 23, 2011 at 12:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.