On May 9, 2012, at 1:21 PM, <[email protected]> 
<[email protected]> wrote:

> 1. If I don't know what attributes exist in the database there is no way
> to write a query about those attributes on documents.

Usually you know something about the schema of the data in a database before 
writing code to operate on it. CouchDB doesn’t enforce any schema, but you’d 
generally define what properties you put in documents beforehand.

What kind of program are you writing? I’m not an RDBMS guru but I’ve written 
some apps that use SQL databases, and I haven’t had to introspect the metadata 
of the table columns. I’ve defined my tables and then written my queries using 
the columns I defined.

Keep in mind that, to some degree, it doesn’t make sense to ask ‘what 
attributes exist in the database’ because every document could have a different 
set of attributes. It’s very unlikely but possible. CouchDB has nothing 
comparable to ‘columns’ in SQL; every document is an independent bag of JSON.

> 2. If I create my own attribute of a document which stores metadata for
> that document it works but if that metadata attribute isn't a required
> attribute for all docs then how can I enforce the collection of metadata
> which supports #1 above?

You can add a validation function to a design document that will enforce the 
presence of that attribute, or any structure you want your documents to have.

> 3. I can create a attribute that would provide a description of a
> document, e.g.#2 above (aka metadata) but how do I create an attribute of
> a document attribute? (e.g. an description for a document attribute called
> "telephone", which is now an attribute of an attribute or meta-attribute)?

I really have no idea where you’re going with this. It’s awfully abstract. What 
are you trying to accomplish?

—Jens

Reply via email to