Wednesday, October 29, 2008

Document-oriented Data Storage

There seems to be new interest in the concept of storing data as documents instead of tables. This is the approach that Lotus Notes took. Here is what I ahave found out so far...

A 'document' is basically a hashtable. You can store values with keys. Solutions then seem to take the Google "Map Reduce" approach to querying the data.

CouchDB allows you to define views. A view contains the results of executing a specified javascript function against each document. This is equivolent to the Google 'Map' step.

RDDB (a ruby implementation) provides for both steps...
  # First create an database object
database = Rddb::Database.new

# Put some documents into it
database << {:name => 'John', :income => 35000}
database << {:name => 'Bob', :income => 40000}
database << {:name => 'Jim', :income => 37000}

# Create a view that will return the names
database.create_view('names') do |document, args|
document.name
end

# The result of querying will return an array of names
assert_equal ['John','Bob','Jim'], database.query('names')


"Map Reduce" scales really well across machines, so I am keen to see where this goes.

I'll let you know what I find out.

Anyone got any pointers?
Post a Comment

GitHub Projects