Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 14918 invoked from network); 30 Dec 2009 19:01:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Dec 2009 19:01:44 -0000 Received: (qmail 40606 invoked by uid 500); 30 Dec 2009 19:01:42 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 40517 invoked by uid 500); 30 Dec 2009 19:01:42 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 40507 invoked by uid 99); 30 Dec 2009 19:01:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Dec 2009 19:01:42 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of iberndlu@googlemail.com designates 72.14.220.156 as permitted sender) Received: from [72.14.220.156] (HELO fg-out-1718.google.com) (72.14.220.156) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Dec 2009 19:01:31 +0000 Received: by fg-out-1718.google.com with SMTP id 19so719179fgg.5 for ; Wed, 30 Dec 2009 11:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:subject:from:content-type :message-id:date:to:content-transfer-encoding:mime-version:x-mailer; bh=9BWGfvEJP4yWf6w9U2dZ7CU0yc1rYzx8ylMLJYQ7HC8=; b=h9vjBzN8jPvX1YEWMjhvdYtbvBMdTPB0FxKkoT0zdti7ft521VZScdKfcUz0zPG3zo 1I1zTAkBcqzgQDTSSImkF6JfWqm7o3iFSQwhNxtj+OyaJPw8/fGrHnbStFeUordvkO74 dP7w0F6e7ZZAVSmhPDc5GFJCZO2ekf2RMeoXE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=subject:from:content-type:message-id:date:to :content-transfer-encoding:mime-version:x-mailer; b=FT+SjTF37EHkqEH+aqLM4F/i5gmWdQ8Hqif/x+d3UdlQIRyV43mWkCiZXAhhxnK47V ZFntlXmUYqmecooxdywYjckNboLgWpWJCh3oIOTW75dtLCK/zREiDlvgmkrXSWSnRiQJ ZtuJ0dh/r3rxLGInF+ZHg7AZkRt6vLuu+yTYQ= Received: by 10.87.67.16 with SMTP id u16mr11071637fgk.20.1262199669940; Wed, 30 Dec 2009 11:01:09 -0800 (PST) Received: from ?192.168.178.29? (mnch-5d85ffcf.pool.mediaWays.net [93.133.255.207]) by mx.google.com with ESMTPS id l19sm40857688fgb.18.2009.12.30.11.01.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 30 Dec 2009 11:01:09 -0800 (PST) Subject: Handling unique URL friendly identifiers From: Bernd Lutz Content-Type: text/plain; charset=us-ascii Message-Id: Date: Wed, 30 Dec 2009 20:01:08 +0100 To: user@couchdb.apache.org Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v1077) X-Mailer: Apple Mail (2.1077) Hello everyone, I'm currently exploring the possibility to port an app from MySQL to = CouchDB. The app uses friendly URLs, e.g. = http://myapp.com/content/friendly-identifier. Every content has an = unique identifier which derives from the content title. If there would be only a few users creating content a simple check for = the identifier's uniqueness would be enough. But what if there are = multiple database nodes and let's say thousand users creating = identifiers. So we cannot get a consistent view result on a single node nor being = sure that another user doesn't add a same identifier on another node in = parallel. I hope you got the problem. How would you handle it? My approach: Setting up a special node and database handling idenifiers with a view = having the identifier as key. 1. Adding a new document with the identifier. 2. Check the uniqueness by queriing the view. 3. If ok, all right. Otherwise: Recursively add a postfix "-n" until the = result is unique. Of course the identifier won't be used as document _id. I think this is a common problem not only for url friendly identifiers. = A common usage could be also the unique user name. Best regards and a happy new year, Bernd=