incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Freddy Bowen <frederick.bo...@gmail.com>
Subject Re: Defining my document model when the source is entity-relationship
Date Thu, 09 Jul 2009 20:56:26 GMT
On Thu, Jul 9, 2009 at 4:16 PM, Vlad GURDIGA <gurdiga@gmail.com> wrote:

> I apologize for the fact that I may be a little off-topic but reading
> this article a question came up regarding the second model presented
> in the "One to Many: Embedded Documents" section:
>
> {
>  "_id":"Scott",
>  "type":"contact",
>  "name":"My Friend Scott",
>  "phones":[{"home":"(650) 555 - 2200"},{"mobile":"(650) 555 - 2201"}],
> }
>
> What is the pros and cons of having phones stored as an array of
> associative hashes versus having them as an associative hash? Here is
> what I mean:
>
> {
>  "_id":"Scott",
>  "type":"contact",
>  "name":"My Friend Scott",
>  "phones":{"home":"(650) 555 - 2200","mobile":"(650) 555 - 2201"}
> }
>
> It seams to me more intuitive syntax.


An array of associative hashes allows duplicate keys, that is
[{"home":"(650) 555 - 2200"},{"mobile":"(650) 555 - 2201"},{"mobile":"(123)
456- 000"}].  And more generally, the idea is that these are like child
documents of the master.

FB

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message