Sorry if this is a truly newbie question, I'm trying to wrap my head around something like CouchDB.
Let's take a concrete example, invoices and line items. An invoice can have many line items in it.
With a "normal" SQL DB, you would have two tables, say: Invoices, LineItems. And we all know how that works. With a "document oriented" DB you would have Invoice docs, those docs, would directly contain the line items in them, right?
Is it possible (and/or easy) to do a query to get a report on the best selling line items? how do you work that on CouchDB? since they are all contained within Invoice documents... in a SQL DB you would only run a query on the LineItems table.
Jesse Hallett To calculate best selling line items with CouchDB you would create an index using line item ids as keys. You can use a map function to scan through every invoice document and emit each line item's id as a key. You can also create a reduce function to perform an aggregate operation on that index, like calculating the sum of all purchased line item quantities. Finally you pass a query to that map/reduce pair with a key parameter specifying that CouchDB should only aggregate quantities from line items with the given id.
There are instructions online for doing this stuff:
http://www.google.com/search?ie=UTF-8&oe=UTF-8&...
http://sitr.us/2009/06/30/database-queries-the-...