CouchDB to the rescue

Got CouchDB installed on my Fedora box. This thing is sweet. Working with a RESTful JSON/HTTP storage system is so much easier than old-fashioned SQL databases. If I were to store users and a lists of stuff per users where this stuff could be shared among more users in a realtional db, I would create a table for the users indexed on userid, a table for the stuff indexed by stuffid and a table of userid to stuffid relations. Then of course I would need lots of boilerplate code to work with the database.

In CouchDB, I would have a database of users where a user doc is stored under /users/<userid>. The stuff would be stored as documents under /stuff/<stuffid> and the relations would be stored either in the user document or in a separate database /userstuff/<userid>/. An important difference is that no matter if the relation information was stored in the user database or in a separate database, the document stored at that location would have to be replaced whenever stuff is added or removed for a user. This makes me prefer putting the relations in a separate database rather than keep updating the user document.

It was hard to believe that you could get a simpler interface than pure HTTP, but still I had to test CouchRest by Chris Anderson. This made working with CouchDB even easier. With all this stuff in blaze, all development is a breeze since I don’t have to spend time on the nitty-gritty repetitive low-level boilerplate stuff.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.