Hi Andy, and welcome,

You're welcome to either normalize the address out into a separate
document and store the document ID in each of the Person documents or
to leave it as is.

In this example use case I actually think normalization would be
strange unless you were trying to be very careful about data
deduplication and wanted to make a view that could show you groups of
people who live together. But for many applications it's probably
unnecessary to formally "link" the two (identical) addresses stored
within the Person documents.

However, if you do have a problem where it becomes necessary to
atomically update a piece of data normalized out from and referenced
by multiple related documents there is some facility for doing simple
join-like operations with view queries. See the section called "Linked
Documents" in the Introduction to CouchDB Views wiki page[1].

Cheers!

[1] http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Keys_and_values

On Sat, Nov 13, 2010 at 13:49, Andy <[email protected]> wrote:
>
> I new to couch db and just trying to understand how it works in terms of 
> relationships.  I understand there are no joins, and it is ok to duplicate 
> data?I'm curious what the best way is to update an address that is shared 
> between multiple documents, for example here are two Person Documents that 
> share a common address:{"name": "John Doe", "address": {"street": "123 Main 
> St.", "city": "Minneapolis", "state": "MN"}}{"name": "Jane Doe", "address": 
> {"street": "123 Main St.", "city": "Minneapolis", "state": "MN"} }I 
> understand how this could be done in a relational database using FKs.  Thanks

Reply via email to