On Thu, Sep 11, 2014 at 6:19 PM, Eric B <[email protected]> wrote:
> I realize that NoSQL allows me to denormalize a lot of that data (which is
> fine) in order to speed up processing/etc, and the concept of "tables" no
> longer applies.    I'm fine with that.  But where I get lost is how to
> organize similar datasets together in CouchDB.  In MongoDB, they have
> Collections - akin to tables - to help separate data.
>
>
> I don't see anything equivalent in CouchDB.  Which would mean to throw all
> my data into a single "bag"/collection and rely entirely on map
> functions/views to help organize data.  For instance, to retrieve all users
> from the system, I would need a map function that does something like:
>  emit all docs that have a username field.
>
> But then what happens if at a later point in time, I create another
> document that has a username field (which isn't a user)?  It will break my
> code.
>
> So then my second option becomes to assign a "document-type" key to every
> document and then filter upon that.  Where my "document-type" key is akin
> to an organizational/collection name.  It's definitely better, but still
> seems a little odd.
>
> The whole process seems very disorganized.

Having document type field is a good and common practice. In fact,
MongoDB uses the same, but at more high level calling this
"collection". You can implement the same by using document type field
and the view which emits documents by type. More over, you can create
"collections"  (views) across various documents by conditions whatever
you like.

> I understand the concept that NoSQL is exactly that - a key/value store,
> where structure is omitted. But I would have expected at the very least
> some organization ability - no?

CouchDB doesn't tell you how you should organize your data: just shape
them in the way you can use them effectively. If you want to ensure
that documents of certain types (or belongs to specific collection in
terms on mongo) should have specific fields - just create
validate_doc_update function that will check document structure on
write and reject it if it has invalid data.

> Am I missing something basic/obvious in CouchDB?  Or is the concept to use
> separate DBs everytime you want to organize similar data together?  That
> also seems a little odd too.

With separate database you won't be able to run views and other
functions on these data since databases are isolated from each other.

--
,,,^..^,,,

Reply via email to