couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <jch...@gmail.com>
Subject Re: Can I guarantee uniqueness in a field without using _id?
Date Tue, 13 Jan 2009 01:35:48 GMT
On Mon, Jan 12, 2009 at 5:12 PM, James Marca
<jmarca@translab.its.uci.edu> wrote:
>  It always strikes me
> as a bit of a hack to overload the _id just to use its uniqueness
> features.  But given that one *can* get unique fields, I'd guess there
> are other things for the developers to solve first.


Supporting multiple unique keys would not lead us closer to the goal
of getting CouchDB to provide its current HTTP API, even when run
across a partitioned cluster of very many nodes.

The same story that applies about global state and uniqueness outside
of CouchDB also applies inside. The magic of hash functions allow us
to provide a single uniqueness constraint. If you need multiple
distinct unique keys, you'll need to track them as separate documents,
and deal with race conditions in your application. (There may be a
hack to get the _bulk_docs API to help you a little here, but it might
be that _bulk_docs transactions will have go away for the sake of
scalability.) Eventually consistent cluster transactions will be a
good challenge for client libraries.

I can understand the value you find in using multiple keys, but the
best way to get your application into Couch will be design it for
standalone documents. I'm glad it looks like you can get by without
multiple keys, there's a lot you can do with application-controlled
ids.

-- 
Chris Anderson
http://jchris.mfdz.com

Mime
View raw message