I've just started playing around with couchdb and I'm really liking it so far, but I was wondering when you should be creating a new database.
Here's what I mean:
If i were to create a blog on a server with multiple blogs and this was a RDBMS, I'd create a database called fox_blog and create tables and relations for the posts, comments, etc..
Now in CouchDB, I'd simply make 3 document types: posts, comments and user accounts.
But this is my question: Would I make one db called fox_blog and add a 'type' field to each of the documents (e.g., in the posts documents there would be a 'type' field with the value of 'post')? Or would I make a separate db for each document and precede the name with fox_ (e.g., db name would be fox_posts for the posts)? Or are neither of these correct?
Let me know if any of this is unclear, it was a bit hard to explain heh
To create a database open the http://127.0.0.1:5984/_utils/. You will get an Overview/index page of CouchDB as shown below. In this page, you can see the list of databases in CouchDB, an option button Create Database on the left hand side. Now click on the create database link.
Couchdb does not have the concept of collections. However, you can achieve similar results using type identifiers on your documents in conjunction with Couchdb views. When you save a document in Couchdb add a field that specifies the type.
Apache CouchDB (CouchDB (link resides outside IBM)) is an open source NoSQL document database that collects and stores data in JSON-based document formats.
You should create a single database with a type field in each document.
You may want to write a view that returns the document and all its comments together.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With