background preloader

Databases

Facebook Twitter

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 As I said I have decoupled the models from the database, a model doesn’t have permanent access to the database anymore. New Views Testing. 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. Here are some simple admin steps to start/stop MongoDb server # Install MongoDB mkdir /data/lib # Start Mongod server ... Here are some basic example. To speed up the query, index can be used. Data modification happens in place. 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: SELECT * FROM TableA CROSS JOIN TableB This joins "everything to everything", resulting in 4 x 4 = 16 rows, far more than we had in the original sets. 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. Insert The following table presents the various SQL statements related to inserting records into tables and the corresponding MongoDB statements. For more information, see db.collection.insert(). Select The following table presents the various SQL statements related to reading records from tables and the corresponding MongoDB statements.