Hi, I would like to use couchdb for a project but i am unsure how to model it. Basically i will have to store products and theirs respectives prices from several stores. So, for a product product1, for example, i will have a price p1 for store1, a price p2 for store 2 and so on...Considering that those prices will be updated automatically, i was thinking in something like this:
A document for the product with all information about it with id equal to the product reference number example: id:product1 name: Product 1 A document with the price and store id id:89923848298398989d9fsd revision:1 store:45 price:5.67 refcode:product1 updated: timestamp here id:8992384829832938495298345 revision:3 store:46 price:3.67 refcode:product1 updated: timestamp here My idea is that each store will update their own prices. Now the problem i am no sure how to solve is that i can have multiple price documents with differents ids (see example below) for the same store (a database inconsistency). Could i use mapreduce to collect all the price documents for a specific product and get only the latest one based on the time is updated. If so, how can i do that? i mean, how would be the map and reduce function? I would also like to delete the old ones. id:8992384829832938495298345 revision:1 store:46 price:3.67 refcode:product1 updated timestamp here id:92839198234 revision:1 store:46 price:6.23 refcode:product1 updated timestamp here I would appreciate any help -- "A realidade de cada lugar e de cada época é uma alucinação coletiva." Bloom, Howard
