Surprise :) There is no established type declarations in couchdb.
Once you get used to it, it is very liberating to work outside the
confines of an established type system. Big hint, the separate db
approach is not where you want to go. But you are on track with using
a 'type' attribute. I have also used views for more simpler schemas,
such as a simple contact database might have views for 'contacts/
people' and 'contacts/companies' based on something like "if
(doc.company_name) //I'm a company" and "if (doc.first_name ||
doc.last_name) //I'm a person"
With all that said, we are using a dynamic language for the app (Ruby)
and although there are some things we are scratching our heads on the
query side, we are crazy nuts excited about everything else,
especially how easily we push data between couch and Ruby.
-- troy
On Jul 15, 2008, at 9:39 PM, Avi Flax wrote:
Hi, I'm new to couchdb, and I apologize if this is a FAQ, but I
can't seem
to find what I'm looking for anywhere.
I'm trying to understand the intended usage pattern for applications
using
couchdb as a data store. Specifically, I'm wondering what the intended
approach to differentiating between different types of documents are.
For example, if my application has two entities: Cars and Trucks, in
a RDBMS
I'd create two different tables; one to store Cards and one to store
Trucks.
If I wanted cars I'd run a query on the "cars" table; if I wanted
trucks I'd
run a query on the "trucks" table.
I'm a little unclear on how to achieve a similar use case with
couchdb. I
guess I could create separate databases for Cars and Trucks, but that
doesn't seem right; I'm dubious that the designers intended
databases to be
used like tables. In searching the mailing list I saw that some
documents
had a field named "type". That seems like a good way to differentiate
document types; my hesitation there is that it just seems very ad-
hoc; I'd
be surprised if there's no more firmly established method for
distinguishing
between document types.
Apologize if this doesn't make much sense, I'm up later than I
should be.
Thanks!
--
Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com