views:

41

answers:

1

I'm new to CouchDB and want to give it a try. But before I do that I want to know if I can create dynamic database structure in CouchDB.

Eg.

  1. The user starts on a blank thread and chooses whatever structure he/she wants (eg. title, body and tags and fill them in)
  2. When he clicks save thread the database for this is created, maybe nested if necessary.
  3. Then the user could get the thread from the database and read it.

Questions:

  1. Is this dynamic creation of database structure possible?

  2. I also read that you have to predefine views that will be used to get the documents. But how can you predefine views for data that yet doesn't exist and you have no idea what data and structure the user is going to create.

+1  A: 
  1. Yes, CouchDB's document appear from the outside like a JSON object in which you can put whatever you want except probably for a few reserved fieldnames for handling document ids and revisions.
  2. These "predefined" views are themselves just documents, so you can modify them dynamically.

If what you require is more in the direction of searching then there are some ways out there to integrate solr with CouchDB which provides a more dynamic approach to queries.

Horst Gutmann
But I've heard if you modify them dynamically you have to reindex your whole database again and it would take a long time. And what if you create a document, you have to create the view immediately? so always data + view documents sent to the couchdb server? But what about the second data insertion then? Will the same view be sent to the couchdb server?
never_had_a_name
I don't know your exact use-case, but don't you have common ways to access most of the data sets? With those you could for instance create pre-defined views that handle most access paths and then create the additional views not completely dynamically but through some nightly job (if your project is limited to a single (or neighboring) regions). Depending on your actual use-case CouchDB might not be the perfect solution for your problem, so you might need some system that offers a more dynamic approach to queries like MongoDB et al.
Horst Gutmann