Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E2B1077F5 for ; Mon, 7 Nov 2011 11:06:23 +0000 (UTC) Received: (qmail 97269 invoked by uid 500); 7 Nov 2011 11:06:22 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 97241 invoked by uid 500); 7 Nov 2011 11:06:22 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 97233 invoked by uid 99); 7 Nov 2011 11:06:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 11:06:22 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [212.227.17.8] (HELO moutng.kundenserver.de) (212.227.17.8) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 11:06:14 +0000 Received: from dhcp-10-114-98-48.virgin.passengerwifi.com ([78.40.152.129]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MhrpH-1RZnEy3t6R-00MWT8; Mon, 07 Nov 2011 12:05:53 +0100 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: Best way to model historical data From: Robert Johnson In-Reply-To: Date: Mon, 7 Nov 2011 11:05:44 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1084) X-Provags-ID: V02:K0:asyqyhyOLYEsPABhHn/X0bYYKBsV0wmMc6eOU5AKmgc enmdGB5eBJDNgMnJabJAy4jgxIKM4IgPE28kiCdhnzqLUl0YZk 50bvZ3IyN4Aiwzm87q90ZpfGseW5/paCVnusSQlGEDqGaSE34A iorXEDOY841bCvJuDv3OXGi8Slmp4/NoII8DFFm/WDxKsKiVLi N6qJhlfQLngDbcjkEwU3VipDoIYEgK4EbNWy+d0R2YObM8L8ZP la+Dc6qs8X4QRO0Riyr/FiWC9j3JWhVeGKoUDhqC6JXJZMIJum 29TK9F36sOUVdn3Ske0saS+SejZWCBFDTWdyM70J6Sk46VI9oY cYb0H/gpsfzfcnhAT9y/uoqoNc9V/m1RPQzsNQKx8dK+eSuzjy PmaKqof3dzQn6bdfErYaaNu2ELyzldMA64O98fthgAldGGo8na uwZB5 X-Virus-Checked: Checked by ClamAV on apache.org I wouldn't use multiple documents, but have a single document that has = arrays of things that might change over time that you want to keep = history for. In your example you would have a block representing categories looking = something like {"categories": { "category_set": [ "2011-10-05", "Components", "Resistors", "Surface Mount" ] "category_set": [ "2011-11-02", "Components", "Resistors", "Surface Mount", "Low Tolerance" ] } } This way you keep a full dated history of changes and you only have to = read a single document and last element in the array is the current one = (clearly you would have to be ensure you update code to ensure always = appended to the array) Bob On 7 Nov 2011, at 09:51, couchdb - Andr=E9s Orencio - lodopidolo wrote: > What you propose is to have a document initially and any other future > changes as new document parts (of the original document), those = reference > to the previous document parts until the initially document. Is this > correct? >=20 > But it has a problem to construct the document to the last state = because > must read all documents changes and apply all to the original = document. A > view could do it? >=20 > What do you think? >=20 >=20 >=20 >=20 > 2011/11/2 Alexander Shorin >=20 >> Hi, >>=20 >> "Each document represents some completed state(event - it just was as >> it is and history couldn't be changes) and doesn't affected from >> external data" - start from this point(; To reduce document size you >> may include related document _id and all vital fields that shouldn't >> be changed in time for it. >>=20 >> Another approach is keeping references both to _id and _rev of = related >> document, but all would be broken if someone runs database compaction >> (also this method doesn't works for views). >>=20 >> -- >> ,,,^..^,,, >>=20 >>=20 >>=20 >> On Wed, Nov 2, 2011 at 2:20 PM, couchdb - Andr=E9s Orencio - = lodopidolo >> wrote: >>> Hello. I'm new in couchdb. >>>=20 >>> I have some questions but I'm going to put them in separate threads. >>>=20 >>> For this, I want ask you which is the better way to store documents = and >> its >>> historical states. >>>=20 >>> For example, I have products documents and categories documents. = Products >>> has one or more categories. This "relation" may change in the time, = and >>> product characteristics can change to. >>>=20 >>> I want to store all document changes (categories too). >>>=20 >>> Which is the better way to do this? >>>=20 >>> Thanks you. >>>=20 >>=20