41

Tonight in my daily tech Googling I came across couchDB, after seeing tons of presentations about how it perform ten to hundred times better then any RDBM, how it would save us from SQL languages, tables, primary keys and so much more. I decided myself to try it myself. Only problem it seems I am unable to figure out how it works.

Like for a start I would like to code a web contact manager using couchDB. The project would enable user to do basic stuff like

  • Create/ Edit / Delete contacts
  • see a list of their contact ordered
  • search them on various criteria

So how do I start ?

Here some of my thoughts

  • create a database per user like July, Ann
  • in those DB, add some document with type contact, the document would look like this at first place see code 1
  • create / edit / delete is straight forward just need to do the PUT, POST, DELETE in the good database
  • searching would be handled by couchdb-lucene like dnolen suggested

now here come the difficult part, I don't really understand the whole map/reduce concept and how I can use that to do the jobs I used to do with SQL. Also with views how do you handle paging, also grouping.

I would like to build a screen with a paging set of links something like this

John, Doe
Johny, Hallyday
Jon, Skeet

A B C D E F **J** etc .... <-- those are link to see persons with that first name

what view should I create to achieve that, if you can provide samples it would wonderful.


Contact document.

{
    type: 'contact',
    firstname: 'firstname',
    lastname: 'lastname',
    email: ['home': 'foobar@foobar.net', 'work': 'foobar@foobar-working.net'],
    phone: ['home': '+81 00 0000 0000'],
    address: []
    ... some other fields maybe ...
}
Dan Rigby
  • 17,133
  • 6
  • 43
  • 60
RageZ
  • 26,800
  • 12
  • 67
  • 76
  • funny I read just the opposite that CouchDB is really slow. As with all erlang software, it's dead slow with 1-4 cores, but only starts to shine when you scale up to 32+ cores – Toad Nov 05 '09 at 13:10
  • 2
    For a similar product but based on c++ you could look at: mongodb – Toad Nov 05 '09 at 13:16
  • 1
    http://www.mongodb.org/display/DOCS/Home – Toad Nov 05 '09 at 15:30
  • @reinier I mean for the benchmarking article – RageZ Nov 06 '09 at 02:39
  • sorry everyone to kind of change my question in the middle but I really want to see implementation in detail, I am planning to talk my manager to use it, so I need to master the subject before doing any moves. – RageZ Nov 06 '09 at 02:55
  • rage: http://www.snailinaturtleneck.com/blog/?p=74 just search for couchdb and slow – Toad Nov 06 '09 at 07:27
  • rage: also: I thought couch was still in beta/alpha and things could still change a lot... mongo is almost at 1.0 and except for bugfixes, nothing is changing anymore – Toad Nov 06 '09 at 07:30

3 Answers3

24

The upcoming book by O'Reilly is free to read online: http://books.couchdb.org/relax/

Just install and play around - you can do straight http requests using curl on the command line, or use the built-in web interface called futon.

Storing and retrieving data is really easy, the hardest part is thinking in terms of map/reduce-views instead of sql queries.

  • thanks for the link actually the book is more detailed then the couch DB documentation .... – RageZ Nov 06 '09 at 03:00
  • 1
    actually the CouchDB API Documentation is better than a lot of projects. It's kept up to date and accurate. But like all API documentation it's not a cookbook it's a reference work. – Jeremy Wall Nov 06 '09 at 17:27
  • 1
    FYI: Read the draft version of the book? It seems to have the errors fixed. The latest does not. – gman Jun 03 '14 at 08:38
8

IBM has a great tutorial, making use of curl to read/write via the REST interface.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
6

Your application is quite easy to do with CouchDB. You would have a database per user. Contacts are simply documents in a particular user's database. CRUD is just talking to the database using HTTP. You could create views that emit keys (last name, first name) to allow for sorting.

For powerful search I would recommend couchdb-lucene.

dnolen
  • 18,496
  • 4
  • 62
  • 71