title: Combining noSQL and ORM in an MVC framework for a real-case application
body: <p>I've been trying for some time to put some 'cool' things I've been reading about noSQL (couchDB, mongoDB, Redis...) in the past years into practical use.</p>
  
  <p>I'm quite used to writing apps with Django, and started using Play! when Java is the only acceptable deployment option (and enjoying it too). Both have modules to work, for instance, with <a href="http://www.mongodb.org/" rel="nofollow noreferrer">MongoDB</a>, and django also has <a href="http://www.allbuttonspressed.com/projects/django-nonrel" rel="nofollow noreferrer">nonrel</a>. But i never felt a need for noSQL.</p>
  
  <p>Until I finally found what I thought was a good use case for document-oriented storage, such as MongoDB.</p>
  
  <h2>Use Case</h2>
  
  <p>Let's say we have to manage ordering and follow up (whatever) of some complex items. The items might have a lot of different properties, eg. oversimplifying we could have:</p>
  
  <ul>
  <li>a Fridge that can have 
  
  <ul>
  <li>one or two doors, </li>
  <li>be of class A,B or C, </li>
  <li>a surface color</li>
  <li>standalone or built-in</li>
  </ul></li>
  <li>an Oven that can have:
  
  <ul>
  <li>gas or electricity or both</li>
  <li>self cleaning or not</li>
  <li>standalone or built-in</li>
  </ul></li>
  </ul>
  
  <h2>SQL/ORM solution</h2>
  
  <p>As you can see, each object can have several properties that can be constrained by type.</p>
  
  <p>In my usual RDBMS through an ORM I would go with defining a "product" model, then inherit two models, a Fridge and an Oven.
  If a Fridge gets one more property some time after, I modify the model - and as such, the schema-, run a migration, and add a column.</p>
  
  <h2>noSQL solutions</h2>
  
  <p>noSQL solutions I can think of are:</p>
  
  <ul>
  <li>using RDF (with something like <a href="http://virtuoso.openlinksw.com/" rel="nofollow noreferrer">Virtuoso</a> or building my own simplified triples storage)</li>
  <li>using a document-oriented db such as MongoDB</li>
  </ul>
  
  <h2>The Problem</h2>
  
  <p>But <strong>I fail at understanding how different (easier) development would <em>pragmatically</em> be</strong> switching to a noSQL solution still using the framework ORM with the right adapter (especially with DODB).</p>
  
  <p>Let's say I'm using Django with MongoDB through mongodb-engine.</p>
  
  <p>I'm still using the same ORM, so I still describe those objects as models, listing all properties. 
  The ORM is thus doing exactly the same job!
  The cost of producing a migration if the model changes is very limited with an ORM (in particular with something like South), nothing requiring to learn a new technology by itself.</p>
  
  <p>There might be /other/ advantages to a DODB, and some specific to MongoDB (scalability, data-processing, maybe performance) but... what about the exact use case and problem I'm describing?</p>
  
  <p>I am most likely missing a point, so here come the real question(s):</p>
  
  <p>For this specific use case: </p>
  
  <ul>
  <li>is this example a good or bad one for DODB (do you have a good one)?</li>
  <li>would it make sense to combine an ORM for basic stuff (Users, Orders) and usage of noSQL <strong>without</strong> ORM for complex objects, is there a compelling reason to switch to noSQL completely, or should I stay with the stock ORM/SQL?</li>
  </ul>
  
  <p>I understand answering these questions could be partially subjective, so you can assume perfect knowledge of both noSQL and SQL theory, and stock ORM; existence of good bridges from stock ORMs to noSQL DB. Let's assume we are talking about this use case with MongoDB as noSQL alternative.</p>
  
  <p>But there is a more general question - which is the core question of this SO post:</p>
  
  <ul>
  <li><strong>Isn't a good ORM (such as JPA, ActiveRecord, or Django's one) making noSQL and in particular document-oriented databases of little use?</strong></li>
  <li>...and is it worth using noSQL with a 'classic' ORM?</li>
  </ul>
  
  <p>("little use" from a programming and maintenance standpoint, performance and similar criteria are a different matter and would require a precise product-to-product comparison)</p>
  
  <p><strong>[edit]</strong></p>
  
  <p>What I am also trying to understand is if it wouldn't be better to drop using an ORM when switching to noSQL. It would be nice to have more "dynamic" models, eg. I could have a table describing what the Fridge and Oven <em>models</em> are (fields), and the Fridge and Oven models in the code would be able to construct their views dynamically (forms for editing and listings for displaying).</p>
  
  <h2>Related questions:</h2>
  
  <p><strong>[edit]</strong>: these are here to show my research, but also to clarify that what I am asking is not generic about noSQL vs. SQL</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2694044/is-an-orm-redundant-with-a-nosql-api">Is an ORM redundant with a NoSQL API?</a> : similar! but I am trying to see why most frameworks (see above) are providing noSQL access through their ORMs. Is that a good idea or not?</li>
  <li><a href="https://stackoverflow.com/questions/8051614/why-the-use-of-an-orm-with-nosql-like-mongodb">why the use of an ORM with NoSql (like MongoDB)</a> : more specific than the previous one, but still is the other way around. I'm arguing that <strong>ORMs make noSQL unuseful</strong>, rather than the other way around!</li>
  <li><a href="https://stackoverflow.com/questions/3522069/when-to-replace-rdbms-orm-with-nosql">When to replace RDBMS/ORM with NoSQL</a></li>
  <li><a href="https://stackoverflow.com/questions/1476295/when-to-use-mongodb-or-other-document-oriented-database-systems">When to use MongoDB or other document oriented database systems?</a></li>
  <li><a href="https://softwareengineering.stackexchange.com/questions/54373/when-would-someone-use-mongodb-or-similar-over-traditional-rdms">https://softwareengineering.stackexchange.com/questions/54373/when-would-someone-use-mongodb-or-similar-over-traditional-rdms</a></li>
  </ul>
  
  <p><strong>EDIT</strong>
  And links:</p>
  
  <ul>
  <li><a href="http://www.sienaproject.com/index.html" rel="nofollow noreferrer">Siena</a>: a persistence API for Java inspired by the Google App Engine Python Datastore trying to draw a bridge between SQL and NoSQL worlds.</li>
  <li><a href="https://github.com/slacy/minimongo" rel="nofollow noreferrer">minimongo</a>:  lightweight, schemaless, Pythonic Object-Oriented interface to MongoDB</li>
  </ul>