You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "c.Kleinhuis" <ck...@digitalgott.de> on 2010/05/13 11:57:18 UTC
Linking of Documents / Attachments
Hello all,
i just decided to use couchdb in favor of hibernate/spring ... my name
is christian kleinhuis
and i have some general questions:
1. How is linking of documents solved ?
i would like to have something like a root node ( Project )
and i would like to associate nodes ( tasks ) to this root node,
what is the way to do it with couchdb ?
do i use the "_id" of the projekt in my task document, or do i
add the tasks as fields in the project ? but thus i couldnt edit a
single
task hence it hasnt an id ...
2. handling attachments ... are the attached files configurable in the
file system, so that a user could go in the attachments folder and see
the files directly ?!
thanks in advance
ck
Re: Linking of Documents / Attachments
Posted by Matt Goodall <ma...@gmail.com>.
On 13 May 2010 12:09, c.Kleinhuis <ck...@digitalgott.de> wrote:
> thank you for your answer
>>>
>>> i just decided to use couchdb in favor of hibernate/spring ... my name is
>>> christian kleinhuis
>>>
>>> and i have some general questions:
>>>
>>> 1. How is linking of documents solved ? i would like to have
>>> something
>>> like a root node ( Project )
>>> and i would like to associate nodes ( tasks ) to this root node,
>>> what is the way to do it with couchdb ?
>>> do i use the "_id" of the projekt in my task document, or do i
>>> add the tasks as fields in the project ? but thus i couldnt edit a
>>> single
>>> task hence it hasnt an id ...
>>>
>>
>> It really depends on the application, but a reasonable rule of thumb
>> is to store things that tend to get edited on their own in separate
>> documents. Certainly, In terms of projects and tasks I would expect a
>> project document and lots of task documents. However, something like a
>> person and his addresses almost certainly makes more sense in a single
>> document.
>>
>
> i meant, how do i associate the tasks with a certain project, assuming that
> many projects
> can be created
Ah, I thought you were just trying to decide between the two solutions
you had identified ;-).
You need to include the _id of the project somewhere in each task
document. Read http://www.cmlenz.net/archives/2007/10/couchdb-joins
for a simple example of how you might "join" the project and tasks in
a single view.
Personally, I like to represent the link from task to project as an
{"_id": "project1"} object as it allows you to *optionally* include
extra, denormalised information about the project in the link object,
e.g.:
= project =
{
"_id": "project1",
"type": "project",
"name": "Project #1",
... lots of other stuff ...
}
= task =
{
"_id": "task1",
"type": "task",
"title": "Fix things",
"project": {"_id": "project1", "title": "Project #1"},
... lots of other stuff ...
}
Hope that helps more now.
- Matt
>
>
>>
>>>
>>> 2. handling attachments ... are the attached files configurable in the
>>> file system, so that a user could go in the attachments folder and see
>>> the files directly ?!
>>>
>>
>> Attachments are stored in the database (and are replicated to other
>> databases just like documents) but there is a FUSE driver that lets
>> you map a database to the file system,
>> http://code.google.com/p/couchdb-fuse/.
>>
>
> cool, thx for pinpointing
>
>
Re: dumb question about how to start couchapp on windows
Posted by "c.Kleinhuis" <ck...@digitalgott.de>.
ah, i see, i need py2exe , installation failed ... :)
> hello,
>
> i installed python, and the easy install, after running
>
> "easyinstall.exe couchapp"
>
> everything worked fine, but my question now is, how do i start that
> app !?
>
> thx in advance
>
> ck
>
dumb question about how to start couchapp on windows
Posted by "c.Kleinhuis" <ck...@digitalgott.de>.
hello,
i installed python, and the easy install, after running
"easyinstall.exe couchapp"
everything worked fine, but my question now is, how do i start that app !?
thx in advance
ck
Re: Linking of Documents / Attachments
Posted by "c.Kleinhuis" <ck...@digitalgott.de>.
thank you for your answer
>>
>> i just decided to use couchdb in favor of hibernate/spring ... my name is
>> christian kleinhuis
>>
>> and i have some general questions:
>>
>> 1. How is linking of documents solved ? i would like to have something
>> like a root node ( Project )
>> and i would like to associate nodes ( tasks ) to this root node,
>> what is the way to do it with couchdb ?
>> do i use the "_id" of the projekt in my task document, or do i
>> add the tasks as fields in the project ? but thus i couldnt edit a single
>> task hence it hasnt an id ...
>>
>
> It really depends on the application, but a reasonable rule of thumb
> is to store things that tend to get edited on their own in separate
> documents. Certainly, In terms of projects and tasks I would expect a
> project document and lots of task documents. However, something like a
> person and his addresses almost certainly makes more sense in a single
> document.
>
i meant, how do i associate the tasks with a certain project, assuming
that many projects
can be created
>
>> 2. handling attachments ... are the attached files configurable in the
>> file system, so that a user could go in the attachments folder and see
>> the files directly ?!
>>
>
> Attachments are stored in the database (and are replicated to other
> databases just like documents) but there is a FUSE driver that lets
> you map a database to the file system,
> http://code.google.com/p/couchdb-fuse/.
>
cool, thx for pinpointing
Re: Linking of Documents / Attachments
Posted by Matt Goodall <ma...@gmail.com>.
On 13 May 2010 10:57, c.Kleinhuis <ck...@digitalgott.de> wrote:
> Hello all,
>
> i just decided to use couchdb in favor of hibernate/spring ... my name is
> christian kleinhuis
>
> and i have some general questions:
>
> 1. How is linking of documents solved ? i would like to have something
> like a root node ( Project )
> and i would like to associate nodes ( tasks ) to this root node,
> what is the way to do it with couchdb ?
> do i use the "_id" of the projekt in my task document, or do i
> add the tasks as fields in the project ? but thus i couldnt edit a single
> task hence it hasnt an id ...
It really depends on the application, but a reasonable rule of thumb
is to store things that tend to get edited on their own in separate
documents. Certainly, In terms of projects and tasks I would expect a
project document and lots of task documents. However, something like a
person and his addresses almost certainly makes more sense in a single
document.
> 2. handling attachments ... are the attached files configurable in the
> file system, so that a user could go in the attachments folder and see
> the files directly ?!
Attachments are stored in the database (and are replicated to other
databases just like documents) but there is a FUSE driver that lets
you map a database to the file system,
http://code.google.com/p/couchdb-fuse/.
- Matt