oreilly / couchdb-guide

CouchDB: The Definitive Guide
http://guide.couchdb.org/
501 stars 139 forks source link

Enforcing Uniqueness (View Cookbook for SQL Jockeys) #419

Open selcuk opened 13 years ago

selcuk commented 13 years ago

Enfrocing Uniqueness: You are describing a way to imitate "primary keys", not unique indexes. There may be more than one unique index per table/document. You need to give examples for this requirement, too.

rwilczek commented 10 years ago

Two additions to that:

  1. SQL allows composite unique (and primary) keys. In CouchDB, _id is a literal string.
  2. In SQL, the parts of an unique key may allow NULL. In CouchDB, _id is mandatory.
  3. In SQL, tables allow an arbitrary number of unique key constraints. In CouchDB, there is only one _id per document (selcuk mentioned that 3 years ago ...)

So enforcing uniqueness in CouchDB is far from being "an easy one". Uniqueness actually is one of the weaknesses of CouchDB.