You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Johnny Weng Luu <jo...@gmail.com> on 2011/07/09 20:39:51 UTC

RESTful document structure

Since CouchDB is implementing a RESTful API, doesn't that mean I wanna put
all documents of the same type in their own database?

eg.

POST http://localhost/users
GET http://localhost/users/1
PUT http://localhost/users/1
DELETE http://localhost/users/1

POST http://localhost/threads
GET http://localhost/threads/1
PUT http://localhost/threads/1
DELETE http://localhost/threads/1

Rather than putting them all in one big database (http://localhost/my_app).

Doesn't a 100% RESTful approach mean that the former is more correct?

Re: RESTful document structure

Posted by Jason Smith <jh...@iriscouch.com>.
On Mon, Jul 11, 2011 at 3:11 AM, Mark Hahn <ma...@boutiquing.com> wrote:
>> you could make one single class (ClassToRuleThemAll, let's say) to
> hold the data for every single data type you work with, but that's silly.
>
> It's silly because there is a practical disadvantage in that every
> instance would waste space for all the variables that would be needed.
>
> I can't think of any practical advantage for having multiple design
> docs unless multiple apps share a db.

CQS uses multiple design documents which are machine-generated.

https://github.com/iriscouch/cqs

You get common access controls, but each queue can be created,
modified, or deleted independently, without affecting the others. In
my deployments, each worker has two queues (2 ddocs), high-priority
and low-priority. Indeed, the real "application" is a distributed
service, built from multiple workers, performing a common task.

I am not satisfied with this architecture. It bothers me to know that
dozens of validation functions execute for each update. Also, if I
change the design doc code, I must re-deploy dozens of times. Changing
validate_doc_update() code is a nightmare. But ultimately, it is a
trade-off and I still feel the benefits outweigh the limitations.

-- 
Iris Couch

Re: RESTful document structure

Posted by "Kevin R. Coombes" <ke...@gmail.com>.
I like the idea that "views are methods and design docs are classes".  
I'm just not convinced that "classes" has to map directly to 
classes/subsets of documents.

Both classes of people who use the system (requesters and service 
providers) deal with the same set of documents: requests.   And the vast 
majority of documents in the database will be requests.  What differs is 
the set of actions/methods that different classes of people can or 
should perform with those documents.  So I still think that splitting 
the design docs to match the main classes of people who interact with 
the system (with the views as their methods) is a reasonable way to do 
things....
     Kevin

On 7/11/2011 9:52 AM, Keith Gable wrote:
> You're obviously free to do whatever you want, but I'd have it split like
> so:
>
> design doc 1: documents that are users
> design doc 2: documents that are requests
> design doc 3: documents that are service providing users (or have
> user.service_provider = true)
>
> Or put another way, consider views to be methods and design docs to be
> classes. Request.by_priority, Request.by_user(startkey=[userid, 0],
> endkey=[userid, {}]), etc.
>
> Since you can have as many design docs as you want and there's a performance
> improvement (at the cost of disk space) of having multiple design docs, why
> not do it this way?
>
> On Mon, Jul 11, 2011 at 9:41 AM, Kevin R. Coombes<kevin.r.coombes@gmail.com
>> wrote:
>> Having just started putting together a db where multiple design docs make
>> sense (at least to me), I can perhaps offer an explanation. We are trying to
>> use couch to track a certain class of service requests.
>>
>> Design doc 1:  All users can make requests, and they can see the status of
>> their requests.
>>
>> Design doc 2: Only the people who actually provide service can look at the
>> full queue and decide whether to accept a request (by assigning it to
>> someone responsible for fulfilling the request) or declining a request (with
>> an explanation).
>>
>> The basic views/interfaces used by the two groups of people are different,
>> so it is actually easiest if the code is separated into differenty design
>> documents.  Since we also tend to implement security through a proxy layer,
>> it is also convenient to have a different class of URLs that can bre
>> controlled by the proxy server, and the design docs make this easy:
>>     /ourdb/_design/users
>> is separate from
>>     /ourdb/_design/workers
>> and so we can put separate controls on who can access them.
>>
>> There is also a third design doc for administrators who can generate
>> reports on how many requests have been received, how many have been acted
>> on, etc. in any given time frame.
>>
>> To me, these do not represent separate apps...
>>
>>     -- Kevin
>>
>>
>> On 7/10/2011 3:11 PM, Mark Hahn wrote:
>>
>>> you could make one single class (ClassToRuleThemAll, let's say) to
>>> hold the data for every single data type you work with, but that's silly.
>>>
>>> It's silly because there is a practical disadvantage in that every
>>> instance would waste space for all the variables that would be needed.
>>>
>>> I can't think of any practical advantage for having multiple design
>>> docs unless multiple apps share a db.
>>>
>>>
>

Re: RESTful document structure

Posted by Keith Gable <zi...@ignition-project.com>.
You're obviously free to do whatever you want, but I'd have it split like
so:

design doc 1: documents that are users
design doc 2: documents that are requests
design doc 3: documents that are service providing users (or have
user.service_provider = true)

Or put another way, consider views to be methods and design docs to be
classes. Request.by_priority, Request.by_user(startkey=[userid, 0],
endkey=[userid, {}]), etc.

Since you can have as many design docs as you want and there's a performance
improvement (at the cost of disk space) of having multiple design docs, why
not do it this way?

On Mon, Jul 11, 2011 at 9:41 AM, Kevin R. Coombes <kevin.r.coombes@gmail.com
> wrote:

> Having just started putting together a db where multiple design docs make
> sense (at least to me), I can perhaps offer an explanation. We are trying to
> use couch to track a certain class of service requests.
>
> Design doc 1:  All users can make requests, and they can see the status of
> their requests.
>
> Design doc 2: Only the people who actually provide service can look at the
> full queue and decide whether to accept a request (by assigning it to
> someone responsible for fulfilling the request) or declining a request (with
> an explanation).
>
> The basic views/interfaces used by the two groups of people are different,
> so it is actually easiest if the code is separated into differenty design
> documents.  Since we also tend to implement security through a proxy layer,
> it is also convenient to have a different class of URLs that can bre
> controlled by the proxy server, and the design docs make this easy:
>    /ourdb/_design/users
> is separate from
>    /ourdb/_design/workers
> and so we can put separate controls on who can access them.
>
> There is also a third design doc for administrators who can generate
> reports on how many requests have been received, how many have been acted
> on, etc. in any given time frame.
>
> To me, these do not represent separate apps...
>
>    -- Kevin
>
>
> On 7/10/2011 3:11 PM, Mark Hahn wrote:
>
>> you could make one single class (ClassToRuleThemAll, let's say) to
>>>
>> hold the data for every single data type you work with, but that's silly.
>>
>> It's silly because there is a practical disadvantage in that every
>> instance would waste space for all the variables that would be needed.
>>
>> I can't think of any practical advantage for having multiple design
>> docs unless multiple apps share a db.
>>
>>


-- 
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Web Developer

Re: RESTful document structure

Posted by "Kevin R. Coombes" <ke...@gmail.com>.
Having just started putting together a db where multiple design docs 
make sense (at least to me), I can perhaps offer an explanation. We are 
trying to use couch to track a certain class of service requests.

Design doc 1:  All users can make requests, and they can see the status 
of their requests.

Design doc 2: Only the people who actually provide service can look at 
the full queue and decide whether to accept a request (by assigning it 
to someone responsible for fulfilling the request) or declining a 
request (with an explanation).

The basic views/interfaces used by the two groups of people are 
different, so it is actually easiest if the code is separated into 
differenty design documents.  Since we also tend to implement security 
through a proxy layer, it is also convenient to have a different class 
of URLs that can bre controlled by the proxy server, and the design docs 
make this easy:
     /ourdb/_design/users
is separate from
     /ourdb/_design/workers
and so we can put separate controls on who can access them.

There is also a third design doc for administrators who can generate 
reports on how many requests have been received, how many have been 
acted on, etc. in any given time frame.

To me, these do not represent separate apps...

     -- Kevin

On 7/10/2011 3:11 PM, Mark Hahn wrote:
>> you could make one single class (ClassToRuleThemAll, let's say) to
> hold the data for every single data type you work with, but that's silly.
>
> It's silly because there is a practical disadvantage in that every
> instance would waste space for all the variables that would be needed.
>
> I can't think of any practical advantage for having multiple design
> docs unless multiple apps share a db.
>

Re: RESTful document structure

Posted by Mark Hahn <ma...@boutiquing.com>.
> you could make one single class (ClassToRuleThemAll, let's say) to
hold the data for every single data type you work with, but that's silly.

It's silly because there is a practical disadvantage in that every
instance would waste space for all the variables that would be needed.

I can't think of any practical advantage for having multiple design
docs unless multiple apps share a db.

Oh well.  It is what it is.

On Sun, Jul 10, 2011 at 1:02 AM, Keith Gable <zi...@ignition-project.com> wrote:
> It's probably a bad idea to mix different applications on the same database
> unless they're related in some way. It's OK to mix different applications on
> the same CouchDB instance.
>
> I somehow think you are equating database to CouchDB instance rather than
> database = document collection running on a CouchDB instance. Design
> documents exist for the same reason that there are classes in OO languages.
> Sure, you could make one single class (ClassToRuleThemAll, let's say) to
> hold the data for every single data type you work with, but that's silly.
>
> On Sat, Jul 9, 2011 at 11:46 PM, Mark Hahn <ma...@boutiquing.com> wrote:
>
>> Thanks.  I think I understand now.  Multiple apps can coexists on one
>> database and you don't want code from different apps mixed together.
>> I've never considered that since I've always had one app, one db.
>> Also I always thought of the views as part of the db, not part of the
>> app.  In something like mysql the indexes are definitely part of the
>> db.
>>
>> Now I can sleep at night.
>>
>> On Sat, Jul 9, 2011 at 9:26 PM, Christian Carter <cd...@gmail.com>
>> wrote:
>> >>
>> >> >  It makes sense
>> >>
>> >> I've asked this same question several times in several ways. The
>> >> answer I've always gotten was that it was logical or made sense.
>> >> Apparently there is no actual purpose for designs.  I know it doesn't
>> >> matter but for some reason it bugs me.
>> >>
>> >
>> > Well, they let you totally self-contain an application, which is super
>> handy
>> > for the couchapp users on the list.  But the main feature is that they
>> make
>> > sense.  You can logically group together things that go together, which
>> can
>> > lead to nice reusable and replicator friendly components.
>> >
>> > Christian Carter
>> >
>> >
>> >
>> >>
>> >> On Sat, Jul 9, 2011 at 6:13 PM, Keith Gable <ziggy@ignition-project.com
>> >
>> >> wrote:
>> >> > I can't really answer your question directly, but I will say that I
>> have
>> >> one
>> >> > design doc for every type (or OO class) of document I have. It makes
>> >> sense
>> >> > when mating CouchDB with a object oriented language (Ruby in my case),
>> >> but
>> >> > YMMV.
>> >> >
>> >> > On Sat, Jul 9, 2011 at 6:59 PM, Mark Hahn <ma...@boutiquing.com>
>> wrote:
>> >> >
>> >> >> In that case, if you say that by definition all docs in one app are
>> >> >> related, then there should be one database, but different design docs
>> >> >> for performance.
>> >> >>
>> >> >> What is the utility of having multiple views in one design doc, other
>> >> >> than being able to edit them in one place?  Or another way to phrase
>> >> >> the same question: why do design docs exist?
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Keith Gable
>> >> > A+ Certified Professional
>> >> > Network+ Certified Professional
>> >> > Web Developer
>> >> >
>> >>
>> >
>>
>
>
>
> --
> Keith Gable
> A+ Certified Professional
> Network+ Certified Professional
> Web Developer
>

Re: RESTful document structure

Posted by Keith Gable <zi...@ignition-project.com>.
It's probably a bad idea to mix different applications on the same database
unless they're related in some way. It's OK to mix different applications on
the same CouchDB instance.

I somehow think you are equating database to CouchDB instance rather than
database = document collection running on a CouchDB instance. Design
documents exist for the same reason that there are classes in OO languages.
Sure, you could make one single class (ClassToRuleThemAll, let's say) to
hold the data for every single data type you work with, but that's silly.

On Sat, Jul 9, 2011 at 11:46 PM, Mark Hahn <ma...@boutiquing.com> wrote:

> Thanks.  I think I understand now.  Multiple apps can coexists on one
> database and you don't want code from different apps mixed together.
> I've never considered that since I've always had one app, one db.
> Also I always thought of the views as part of the db, not part of the
> app.  In something like mysql the indexes are definitely part of the
> db.
>
> Now I can sleep at night.
>
> On Sat, Jul 9, 2011 at 9:26 PM, Christian Carter <cd...@gmail.com>
> wrote:
> >>
> >> >  It makes sense
> >>
> >> I've asked this same question several times in several ways. The
> >> answer I've always gotten was that it was logical or made sense.
> >> Apparently there is no actual purpose for designs.  I know it doesn't
> >> matter but for some reason it bugs me.
> >>
> >
> > Well, they let you totally self-contain an application, which is super
> handy
> > for the couchapp users on the list.  But the main feature is that they
> make
> > sense.  You can logically group together things that go together, which
> can
> > lead to nice reusable and replicator friendly components.
> >
> > Christian Carter
> >
> >
> >
> >>
> >> On Sat, Jul 9, 2011 at 6:13 PM, Keith Gable <ziggy@ignition-project.com
> >
> >> wrote:
> >> > I can't really answer your question directly, but I will say that I
> have
> >> one
> >> > design doc for every type (or OO class) of document I have. It makes
> >> sense
> >> > when mating CouchDB with a object oriented language (Ruby in my case),
> >> but
> >> > YMMV.
> >> >
> >> > On Sat, Jul 9, 2011 at 6:59 PM, Mark Hahn <ma...@boutiquing.com>
> wrote:
> >> >
> >> >> In that case, if you say that by definition all docs in one app are
> >> >> related, then there should be one database, but different design docs
> >> >> for performance.
> >> >>
> >> >> What is the utility of having multiple views in one design doc, other
> >> >> than being able to edit them in one place?  Or another way to phrase
> >> >> the same question: why do design docs exist?
> >> >
> >> >
> >> >
> >> > --
> >> > Keith Gable
> >> > A+ Certified Professional
> >> > Network+ Certified Professional
> >> > Web Developer
> >> >
> >>
> >
>



-- 
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Web Developer

Re: RESTful document structure

Posted by Mark Hahn <ma...@boutiquing.com>.
Thanks.  I think I understand now.  Multiple apps can coexists on one
database and you don't want code from different apps mixed together.
I've never considered that since I've always had one app, one db.
Also I always thought of the views as part of the db, not part of the
app.  In something like mysql the indexes are definitely part of the
db.

Now I can sleep at night.

On Sat, Jul 9, 2011 at 9:26 PM, Christian Carter <cd...@gmail.com> wrote:
>>
>> >  It makes sense
>>
>> I've asked this same question several times in several ways. The
>> answer I've always gotten was that it was logical or made sense.
>> Apparently there is no actual purpose for designs.  I know it doesn't
>> matter but for some reason it bugs me.
>>
>
> Well, they let you totally self-contain an application, which is super handy
> for the couchapp users on the list.  But the main feature is that they make
> sense.  You can logically group together things that go together, which can
> lead to nice reusable and replicator friendly components.
>
> Christian Carter
>
>
>
>>
>> On Sat, Jul 9, 2011 at 6:13 PM, Keith Gable <zi...@ignition-project.com>
>> wrote:
>> > I can't really answer your question directly, but I will say that I have
>> one
>> > design doc for every type (or OO class) of document I have. It makes
>> sense
>> > when mating CouchDB with a object oriented language (Ruby in my case),
>> but
>> > YMMV.
>> >
>> > On Sat, Jul 9, 2011 at 6:59 PM, Mark Hahn <ma...@boutiquing.com> wrote:
>> >
>> >> In that case, if you say that by definition all docs in one app are
>> >> related, then there should be one database, but different design docs
>> >> for performance.
>> >>
>> >> What is the utility of having multiple views in one design doc, other
>> >> than being able to edit them in one place?  Or another way to phrase
>> >> the same question: why do design docs exist?
>> >
>> >
>> >
>> > --
>> > Keith Gable
>> > A+ Certified Professional
>> > Network+ Certified Professional
>> > Web Developer
>> >
>>
>

Re: RESTful document structure

Posted by Christian Carter <cd...@gmail.com>.
>
> >  It makes sense
>
> I've asked this same question several times in several ways. The
> answer I've always gotten was that it was logical or made sense.
> Apparently there is no actual purpose for designs.  I know it doesn't
> matter but for some reason it bugs me.
>

Well, they let you totally self-contain an application, which is super handy
for the couchapp users on the list.  But the main feature is that they make
sense.  You can logically group together things that go together, which can
lead to nice reusable and replicator friendly components.

Christian Carter



>
> On Sat, Jul 9, 2011 at 6:13 PM, Keith Gable <zi...@ignition-project.com>
> wrote:
> > I can't really answer your question directly, but I will say that I have
> one
> > design doc for every type (or OO class) of document I have. It makes
> sense
> > when mating CouchDB with a object oriented language (Ruby in my case),
> but
> > YMMV.
> >
> > On Sat, Jul 9, 2011 at 6:59 PM, Mark Hahn <ma...@boutiquing.com> wrote:
> >
> >> In that case, if you say that by definition all docs in one app are
> >> related, then there should be one database, but different design docs
> >> for performance.
> >>
> >> What is the utility of having multiple views in one design doc, other
> >> than being able to edit them in one place?  Or another way to phrase
> >> the same question: why do design docs exist?
> >
> >
> >
> > --
> > Keith Gable
> > A+ Certified Professional
> > Network+ Certified Professional
> > Web Developer
> >
>

Re: RESTful document structure

Posted by Mark Hahn <ma...@boutiquing.com>.
>  It makes sense

I've asked this same question several times in several ways. The
answer I've always gotten was that it was logical or made sense.
Apparently there is no actual purpose for designs.  I know it doesn't
matter but for some reason it bugs me.

On Sat, Jul 9, 2011 at 6:13 PM, Keith Gable <zi...@ignition-project.com> wrote:
> I can't really answer your question directly, but I will say that I have one
> design doc for every type (or OO class) of document I have. It makes sense
> when mating CouchDB with a object oriented language (Ruby in my case), but
> YMMV.
>
> On Sat, Jul 9, 2011 at 6:59 PM, Mark Hahn <ma...@boutiquing.com> wrote:
>
>> In that case, if you say that by definition all docs in one app are
>> related, then there should be one database, but different design docs
>> for performance.
>>
>> What is the utility of having multiple views in one design doc, other
>> than being able to edit them in one place?  Or another way to phrase
>> the same question: why do design docs exist?
>
>
>
> --
> Keith Gable
> A+ Certified Professional
> Network+ Certified Professional
> Web Developer
>

Re: RESTful document structure

Posted by Keith Gable <zi...@ignition-project.com>.
I can't really answer your question directly, but I will say that I have one
design doc for every type (or OO class) of document I have. It makes sense
when mating CouchDB with a object oriented language (Ruby in my case), but
YMMV.

On Sat, Jul 9, 2011 at 6:59 PM, Mark Hahn <ma...@boutiquing.com> wrote:

> In that case, if you say that by definition all docs in one app are
> related, then there should be one database, but different design docs
> for performance.
>
> What is the utility of having multiple views in one design doc, other
> than being able to edit them in one place?  Or another way to phrase
> the same question: why do design docs exist?



-- 
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Web Developer

Re: RESTful document structure

Posted by Mark Hahn <ma...@boutiquing.com>.
In that case, if you say that by definition all docs in one app are
related, then there should be one database, but different design docs
for performance.

What is the utility of having multiple views in one design doc, other
than being able to edit them in one place?  Or another way to phrase
the same question: why do design docs exist?

On Sat, Jul 9, 2011 at 1:44 PM, Robert Newson <rn...@apache.org> wrote:
> That's not quite accurate. All views inside the same design document
> are written to the same file and so we update them all at once, but
> each design document can build its views independently. The pivot
> point for view build parallelism is the design document, not the
> database.
>
> Keeping unrelated documents in different databases is just another way
> of saying keep related documents in the same database, which is sane.
>
> B.
>
> On 9 July 2011 21:37, Mark Hahn <ma...@boutiquing.com> wrote:
>> However, the more views, designs, etc. you put in a single db the
>> slower some operations, like updating a view, get.  I tend to use
>> different DBs when I know the data has no inter-connections and has no
>> reason to be combined.  It also feels good to have independent dbs
>> when used by independent modules.
>>
>> The only negative I can think of is having more dbs to manage in
>> operations like replication, but that is just bookkeeping.
>>
>> On Sat, Jul 9, 2011 at 1:29 PM, Robert Newson <rn...@apache.org> wrote:
>>> In CouchDB, most of the important features are scoped at the database
>>> level. For example, views, replication, validation functions, rewrite
>>> rules and _security objects. Separating data into different databases
>>> by type would remove access to almost all the compelling features of
>>> CouchDB, reducing it to a mere document store, not a document
>>> database.
>>>
>>> B.
>>>
>>> On 9 July 2011 21:19, Keith Gable <zi...@ignition-project.com> wrote:
>>>> REST is more concerned with verbs and resources and what happens when you
>>>> combine the two.
>>>>
>>>> The OP is more than welcome to use different databases for each distinct
>>>> type of data, however it makes it more difficult to do stuff and is
>>>> certainly not necessary.
>>>>
>>>> If you think about a CouchDB document as a resource within a collection that
>>>> is your database, it makes sense. VERB /database-collection/document.
>>>> Perfectly RESTful to me.
>>>>
>>>> On Sat, Jul 9, 2011 at 2:35 PM, Robert Newson <rn...@apache.org> wrote:
>>>>
>>>>> REST does not require that you use only one type of document per
>>>>> database. Even if it did, I'd strongly advise violating a rule as
>>>>> silly as that.
>>>>>
>>>>> Put whatever documents into your database as you please.
>>>>>
>>>>> B.
>>>>>
>>>>> On 9 July 2011 19:39, Johnny Weng Luu <jo...@gmail.com> wrote:
>>>>> > Since CouchDB is implementing a RESTful API, doesn't that mean I wanna
>>>>> put
>>>>> > all documents of the same type in their own database?
>>>>> >
>>>>> > eg.
>>>>> >
>>>>> > POST http://localhost/users
>>>>> > GET http://localhost/users/1
>>>>> > PUT http://localhost/users/1
>>>>> > DELETE http://localhost/users/1
>>>>> >
>>>>> > POST http://localhost/threads
>>>>> > GET http://localhost/threads/1
>>>>> > PUT http://localhost/threads/1
>>>>> > DELETE http://localhost/threads/1
>>>>> >
>>>>> > Rather than putting them all in one big database (
>>>>> http://localhost/my_app).
>>>>> >
>>>>> > Doesn't a 100% RESTful approach mean that the former is more correct?
>>>>> >
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Keith Gable
>>>> A+ Certified Professional
>>>> Network+ Certified Professional
>>>> Web Developer
>>>>
>>>
>>
>

Re: RESTful document structure

Posted by Robert Newson <rn...@apache.org>.
That's not quite accurate. All views inside the same design document
are written to the same file and so we update them all at once, but
each design document can build its views independently. The pivot
point for view build parallelism is the design document, not the
database.

Keeping unrelated documents in different databases is just another way
of saying keep related documents in the same database, which is sane.

B.

On 9 July 2011 21:37, Mark Hahn <ma...@boutiquing.com> wrote:
> However, the more views, designs, etc. you put in a single db the
> slower some operations, like updating a view, get.  I tend to use
> different DBs when I know the data has no inter-connections and has no
> reason to be combined.  It also feels good to have independent dbs
> when used by independent modules.
>
> The only negative I can think of is having more dbs to manage in
> operations like replication, but that is just bookkeeping.
>
> On Sat, Jul 9, 2011 at 1:29 PM, Robert Newson <rn...@apache.org> wrote:
>> In CouchDB, most of the important features are scoped at the database
>> level. For example, views, replication, validation functions, rewrite
>> rules and _security objects. Separating data into different databases
>> by type would remove access to almost all the compelling features of
>> CouchDB, reducing it to a mere document store, not a document
>> database.
>>
>> B.
>>
>> On 9 July 2011 21:19, Keith Gable <zi...@ignition-project.com> wrote:
>>> REST is more concerned with verbs and resources and what happens when you
>>> combine the two.
>>>
>>> The OP is more than welcome to use different databases for each distinct
>>> type of data, however it makes it more difficult to do stuff and is
>>> certainly not necessary.
>>>
>>> If you think about a CouchDB document as a resource within a collection that
>>> is your database, it makes sense. VERB /database-collection/document.
>>> Perfectly RESTful to me.
>>>
>>> On Sat, Jul 9, 2011 at 2:35 PM, Robert Newson <rn...@apache.org> wrote:
>>>
>>>> REST does not require that you use only one type of document per
>>>> database. Even if it did, I'd strongly advise violating a rule as
>>>> silly as that.
>>>>
>>>> Put whatever documents into your database as you please.
>>>>
>>>> B.
>>>>
>>>> On 9 July 2011 19:39, Johnny Weng Luu <jo...@gmail.com> wrote:
>>>> > Since CouchDB is implementing a RESTful API, doesn't that mean I wanna
>>>> put
>>>> > all documents of the same type in their own database?
>>>> >
>>>> > eg.
>>>> >
>>>> > POST http://localhost/users
>>>> > GET http://localhost/users/1
>>>> > PUT http://localhost/users/1
>>>> > DELETE http://localhost/users/1
>>>> >
>>>> > POST http://localhost/threads
>>>> > GET http://localhost/threads/1
>>>> > PUT http://localhost/threads/1
>>>> > DELETE http://localhost/threads/1
>>>> >
>>>> > Rather than putting them all in one big database (
>>>> http://localhost/my_app).
>>>> >
>>>> > Doesn't a 100% RESTful approach mean that the former is more correct?
>>>> >
>>>>
>>>
>>>
>>>
>>> --
>>> Keith Gable
>>> A+ Certified Professional
>>> Network+ Certified Professional
>>> Web Developer
>>>
>>
>

Re: RESTful document structure

Posted by Mark Hahn <ma...@boutiquing.com>.
However, the more views, designs, etc. you put in a single db the
slower some operations, like updating a view, get.  I tend to use
different DBs when I know the data has no inter-connections and has no
reason to be combined.  It also feels good to have independent dbs
when used by independent modules.

The only negative I can think of is having more dbs to manage in
operations like replication, but that is just bookkeeping.

On Sat, Jul 9, 2011 at 1:29 PM, Robert Newson <rn...@apache.org> wrote:
> In CouchDB, most of the important features are scoped at the database
> level. For example, views, replication, validation functions, rewrite
> rules and _security objects. Separating data into different databases
> by type would remove access to almost all the compelling features of
> CouchDB, reducing it to a mere document store, not a document
> database.
>
> B.
>
> On 9 July 2011 21:19, Keith Gable <zi...@ignition-project.com> wrote:
>> REST is more concerned with verbs and resources and what happens when you
>> combine the two.
>>
>> The OP is more than welcome to use different databases for each distinct
>> type of data, however it makes it more difficult to do stuff and is
>> certainly not necessary.
>>
>> If you think about a CouchDB document as a resource within a collection that
>> is your database, it makes sense. VERB /database-collection/document.
>> Perfectly RESTful to me.
>>
>> On Sat, Jul 9, 2011 at 2:35 PM, Robert Newson <rn...@apache.org> wrote:
>>
>>> REST does not require that you use only one type of document per
>>> database. Even if it did, I'd strongly advise violating a rule as
>>> silly as that.
>>>
>>> Put whatever documents into your database as you please.
>>>
>>> B.
>>>
>>> On 9 July 2011 19:39, Johnny Weng Luu <jo...@gmail.com> wrote:
>>> > Since CouchDB is implementing a RESTful API, doesn't that mean I wanna
>>> put
>>> > all documents of the same type in their own database?
>>> >
>>> > eg.
>>> >
>>> > POST http://localhost/users
>>> > GET http://localhost/users/1
>>> > PUT http://localhost/users/1
>>> > DELETE http://localhost/users/1
>>> >
>>> > POST http://localhost/threads
>>> > GET http://localhost/threads/1
>>> > PUT http://localhost/threads/1
>>> > DELETE http://localhost/threads/1
>>> >
>>> > Rather than putting them all in one big database (
>>> http://localhost/my_app).
>>> >
>>> > Doesn't a 100% RESTful approach mean that the former is more correct?
>>> >
>>>
>>
>>
>>
>> --
>> Keith Gable
>> A+ Certified Professional
>> Network+ Certified Professional
>> Web Developer
>>
>

Re: RESTful document structure

Posted by Robert Newson <rn...@apache.org>.
In CouchDB, most of the important features are scoped at the database
level. For example, views, replication, validation functions, rewrite
rules and _security objects. Separating data into different databases
by type would remove access to almost all the compelling features of
CouchDB, reducing it to a mere document store, not a document
database.

B.

On 9 July 2011 21:19, Keith Gable <zi...@ignition-project.com> wrote:
> REST is more concerned with verbs and resources and what happens when you
> combine the two.
>
> The OP is more than welcome to use different databases for each distinct
> type of data, however it makes it more difficult to do stuff and is
> certainly not necessary.
>
> If you think about a CouchDB document as a resource within a collection that
> is your database, it makes sense. VERB /database-collection/document.
> Perfectly RESTful to me.
>
> On Sat, Jul 9, 2011 at 2:35 PM, Robert Newson <rn...@apache.org> wrote:
>
>> REST does not require that you use only one type of document per
>> database. Even if it did, I'd strongly advise violating a rule as
>> silly as that.
>>
>> Put whatever documents into your database as you please.
>>
>> B.
>>
>> On 9 July 2011 19:39, Johnny Weng Luu <jo...@gmail.com> wrote:
>> > Since CouchDB is implementing a RESTful API, doesn't that mean I wanna
>> put
>> > all documents of the same type in their own database?
>> >
>> > eg.
>> >
>> > POST http://localhost/users
>> > GET http://localhost/users/1
>> > PUT http://localhost/users/1
>> > DELETE http://localhost/users/1
>> >
>> > POST http://localhost/threads
>> > GET http://localhost/threads/1
>> > PUT http://localhost/threads/1
>> > DELETE http://localhost/threads/1
>> >
>> > Rather than putting them all in one big database (
>> http://localhost/my_app).
>> >
>> > Doesn't a 100% RESTful approach mean that the former is more correct?
>> >
>>
>
>
>
> --
> Keith Gable
> A+ Certified Professional
> Network+ Certified Professional
> Web Developer
>

Re: RESTful document structure

Posted by Keith Gable <zi...@ignition-project.com>.
REST is more concerned with verbs and resources and what happens when you
combine the two.

The OP is more than welcome to use different databases for each distinct
type of data, however it makes it more difficult to do stuff and is
certainly not necessary.

If you think about a CouchDB document as a resource within a collection that
is your database, it makes sense. VERB /database-collection/document.
Perfectly RESTful to me.

On Sat, Jul 9, 2011 at 2:35 PM, Robert Newson <rn...@apache.org> wrote:

> REST does not require that you use only one type of document per
> database. Even if it did, I'd strongly advise violating a rule as
> silly as that.
>
> Put whatever documents into your database as you please.
>
> B.
>
> On 9 July 2011 19:39, Johnny Weng Luu <jo...@gmail.com> wrote:
> > Since CouchDB is implementing a RESTful API, doesn't that mean I wanna
> put
> > all documents of the same type in their own database?
> >
> > eg.
> >
> > POST http://localhost/users
> > GET http://localhost/users/1
> > PUT http://localhost/users/1
> > DELETE http://localhost/users/1
> >
> > POST http://localhost/threads
> > GET http://localhost/threads/1
> > PUT http://localhost/threads/1
> > DELETE http://localhost/threads/1
> >
> > Rather than putting them all in one big database (
> http://localhost/my_app).
> >
> > Doesn't a 100% RESTful approach mean that the former is more correct?
> >
>



-- 
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Web Developer

Re: RESTful document structure

Posted by Robert Newson <rn...@apache.org>.
REST does not require that you use only one type of document per
database. Even if it did, I'd strongly advise violating a rule as
silly as that.

Put whatever documents into your database as you please.

B.

On 9 July 2011 19:39, Johnny Weng Luu <jo...@gmail.com> wrote:
> Since CouchDB is implementing a RESTful API, doesn't that mean I wanna put
> all documents of the same type in their own database?
>
> eg.
>
> POST http://localhost/users
> GET http://localhost/users/1
> PUT http://localhost/users/1
> DELETE http://localhost/users/1
>
> POST http://localhost/threads
> GET http://localhost/threads/1
> PUT http://localhost/threads/1
> DELETE http://localhost/threads/1
>
> Rather than putting them all in one big database (http://localhost/my_app).
>
> Doesn't a 100% RESTful approach mean that the former is more correct?
>