Mgp/iron-cushion. New Couch Potato: simple, testable, opinionated. – Upstream - Agile. May 17, 2009 by alex After my talk about Ruby CouchDB frameworks at Scotland on Rails where I dismissed a few of of the libraries available (including my own Couhch Potato) as not fitting the CouchDB way of doing things, I have been hacking away the past few weeks working on a complete overhaul of Couch Potato.
As a first result I have just released version 0.2 of the framework. Its new goals are simplicity, embracing the CouchDB semantics and testability. In order to achieve this I had to introduce some major changes: I disconnected models from the database - there are no more save/get/find methods in the models. I have dropped associations and thrown away all the ActiveRecord like view creation/querying, replacing it with a new, more CouchDB like system. The following paragraphs will show you how to work with the new Couch Potato. Saving / loading models. MongoDb Architecture. NOSQL has become a very heated topic for large web-scale deployment where scalability and semi-structured data driven the DB requirement towards NOSQL.
There has been many NOSQL products evolving in over last couple years. In my past blogs, I have been covering the underlying distributed system theory of NOSQL, as well as some specific products such as CouchDB and Cassandra/HBase. Last Friday I was very lucky to meet with Jared Rosoff from 10gen in a technical conference and have a discussion about the technical architecture of MongoDb. I found the information is very useful and want to share with more people. One thing I am very impressed by MongoDb is that it is extremely easy to use and the underlying architecture is also very easy to understand.
You Only Wish MongoDB Wasn't Relational. MongoDB = Get Stuff Done Update: Changed blog example to use a normal belongs-to relationship.
Update: Added examples of $slice and $elemMatch to show why they don’t work When choosing the stack for our TV guide service, we became interested in NoSQL dbs because we anticipated needing to scale horizontally. We evaluated several and settled on MongoDB. The main reason was that MongoDB got out of the way and let us get work done. So when you read that MongoDB is a document store, you might get the wonderful idea to store your relationships in a big document.
Several times, we’ve excitedly begun a schema this way, only to be forced to pull the nested documents out into their own collection. Let’s make a blog! Here’s an example. What’s a blog without comments? This works nicely with the key/value idea that you should denormalize your data. When Nested Documents Become a Problem The minute you need just a little control over querying against those comments, you’re stuck. Collections are Cheap. A Visual Explanation of SQL Joins. I love the concept, though, so let's see if we can make it work.
Assume we have the following two tables. Table A is on the left, and Table B is on the right. We'll populate them with four records each. id name id name -- ---- -- ---- 1 Pirate 1 Rutabaga 2 Monkey 2 Pirate 3 Ninja 3 Darth Vader 4 Spaghetti 4 Ninja Let's join these tables by the name field in a few different ways and see if we can get a conceptual match to those nifty Venn diagrams. There's also a cartesian product or cross join, which as far as I can tell, can't be expressed as a Venn diagram: SQL to Mongo Mapping Chart.
In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.
The following table presents the various SQL statements and the corresponding MongoDB statements. The examples in the table assume the following conditions: Create and Alter The following table presents the various SQL statements related to table-level actions and the corresponding MongoDB statements. For more information, see db.collection.insert(), db.createCollection(), db.collection.update(), $set, $unset, db.collection.ensureIndex(), indexes, db.collection.drop(), and Data Modeling Concepts.