You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Justin Walgran <jw...@gmail.com> on 2009/08/07 00:47:36 UTC

Best practice: adding an app specific chunk to a document

I'm building a couch app that works with it's own database of
documents or as an add-in to any existing database of documents. In
the case where the app is added to an existing database, I would like
to scan the documents and add a little "meta" section to each one for
storing information relevant to the app. I am very excited by the idea
of "mix in" applications, but this raises a few questions:

Is it wrong to "pollute" the existing documents with my extra meta section?
Are there any thoughts on the best value to use as a key for my data
section to minimize collisions? Is a single master GUID my only
choice?

Thanks for the feedback.

-Justin

Re: Best practice: adding an app specific chunk to a document

Posted by Justin Walgran <jw...@gmail.com>.
Eric, that is exactly the type of thing I was looking to support in my app.

Are other app developers using the convention of storing app specific
data under a "doc.application_annotations.[namespace]" key?

It seems like agreeing to a standard is a good way to go. That said,
if I had a database of job applicant documents, then the key
"application_annotations" will likely collide with the actual data.
How would you handle this situation in desktopcouch?

-Justin

> We've decided to have things that all applications agree on as a top level
> field in the document, described by a schema (so a contact would have
> first_name and last_name, and some other fields that every application would
> conceaivably be interested in) and then there is a dictionary called
> 'application_annotations' where each application has its own namespace in
> which it can store application specific data, or data that not all
> applications agree on.
>
> This is a flexible way to do things in that it doesn't impose a lot on
> applications that work with it (you don't *have* to look at
> application_annotations if you don't need it, all we ask is that you don't
> delete it) and it makes complicated use cases possible.
>
> [1] https://code.launchpad.net/desktopcouch
>    http://www.freedesktop.org/wiki/Specifications/desktopcouch
>
> --
> - eric casteleijn
> https://launchpad.net/~thisfred
> http://www.canonical.com
>

Re: Best practice: adding an app specific chunk to a document

Posted by eric casteleijn <er...@canonical.com>.
Justin Walgran wrote:
> I'm building a couch app that works with it's own database of
> documents or as an add-in to any existing database of documents. In
> the case where the app is added to an existing database, I would like
> to scan the documents and add a little "meta" section to each one for
> storing information relevant to the app. I am very excited by the idea
> of "mix in" applications, but this raises a few questions:
> 
> Is it wrong to "pollute" the existing documents with my extra meta section?
> Are there any thoughts on the best value to use as a key for my data
> section to minimize collisions? Is a single master GUID my only
> choice?
> 
> Thanks for the feedback.

You might want to check out the way desktopcouch[1] does this: One of 
the intented use cases of desktopcouch is exactly to make databases 
usable by multiple applications that are interested in the same domain. 
(For instance a contacts database that could be used by email 
applications and IM applications and any other application that would 
need to communicate things with other people.)

We've decided to have things that all applications agree on as a top 
level field in the document, described by a schema (so a contact would 
have first_name and last_name, and some other fields that every 
application would conceaivably be interested in) and then there is a 
dictionary called 'application_annotations' where each application has 
its own namespace in which it can store application specific data, or 
data that not all applications agree on.

This is a flexible way to do things in that it doesn't impose a lot on 
applications that work with it (you don't *have* to look at 
application_annotations if you don't need it, all we ask is that you 
don't delete it) and it makes complicated use cases possible.

[1] https://code.launchpad.net/desktopcouch
     http://www.freedesktop.org/wiki/Specifications/desktopcouch

-- 
- eric casteleijn
https://launchpad.net/~thisfred
http://www.canonical.com

Re: Best practice: adding an app specific chunk to a document

Posted by Justin Walgran <jw...@gmail.com>.
I don't believe that is possible, and even if it was, there would not
be a way for user actions to change the document "meta" section at
runtime.

On Thu, Aug 6, 2009 at 7:16 PM, Noah Slater<ns...@apache.org> wrote:
> On Thu, Aug 06, 2009 at 06:47:36PM -0400, Justin Walgran wrote:
>> Is it wrong to "pollute" the existing documents with my extra meta section?
>> Are there any thoughts on the best value to use as a key for my data section
>> to minimize collisions? Is a single master GUID my only choice?
>
> If CouchDB let us create views on views, I guess the most sensible thing to do
> would be to create a view that "injects" your metadata in without altering the
> original document. You could then create additional views on top of this. Of
> course, there are a whole range of possible scenarios where this wouldn't be
> appropriate, but potentially, it's still an interesting idea.
>
> Best,
>
> --
> Noah Slater, http://tumbolia.org/nslater
>

Re: Best practice: adding an app specific chunk to a document

Posted by Noah Slater <ns...@apache.org>.
On Thu, Aug 06, 2009 at 06:47:36PM -0400, Justin Walgran wrote:
> Is it wrong to "pollute" the existing documents with my extra meta section?
> Are there any thoughts on the best value to use as a key for my data section
> to minimize collisions? Is a single master GUID my only choice?

If CouchDB let us create views on views, I guess the most sensible thing to do
would be to create a view that "injects" your metadata in without altering the
original document. You could then create additional views on top of this. Of
course, there are a whole range of possible scenarios where this wouldn't be
appropriate, but potentially, it's still an interesting idea.

Best,

-- 
Noah Slater, http://tumbolia.org/nslater