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 开发者_Python百科is more correct?
The primary reason to use multiple databases is to split the data up because of volume, notably creating new views, compaction, etc. There's no reason logically to split them up.
The simple truth is that the DB doesn't care. Nor do the URLs. Nor do REST. You can easily create a logically similar URL structure within couch using views, or if you find that offensive you can use the built in URL Rewriting functionality with Couch.
REST cares about architecture. REST cares that you use unique URLs. REST cares that you provides links to other resources via their URLs using hypermedia. REST cares that you use ubiquitous media types. Pretty URLs are way down on the list of things REST cares about.
If you want to do REST, focus on architecture and media-types. URLs pretty much handle themselves.
精彩评论