Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B2772B5DD81 for ; Sat, 22 Oct 2011 14:14:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 10139-02 for ; Sat, 22 Oct 2011 17:14:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from ns210619.ovh.net (ns210619.ovh.net [188.165.206.83]) by mail.postgresql.org (Postfix) with ESMTP id 2C703B5DDA0 for ; Sat, 22 Oct 2011 14:14:08 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by ns210619.ovh.net (Postfix) with ESMTP id 0F0D13D1E427; Sat, 22 Oct 2011 19:16:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at ns210619.ovh.net Received: from ns210619.ovh.net ([127.0.0.1]) by localhost (ns210619.ovh.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ffZRSeVUynK0; Sat, 22 Oct 2011 19:16:04 +0200 (CEST) Received: from [192.168.1.4] (62.87.220.87.dynamic.jazztel.es [87.220.87.62]) by ns210619.ovh.net (Postfix) with ESMTPA id 1B66F3D1E424; Sat, 22 Oct 2011 19:16:04 +0200 (CEST) Message-ID: <4EA2F9DD.2040106@linos.es> Date: Sat, 22 Oct 2011 19:14:05 +0200 From: Linos User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20111001 Thunderbird/7.0.1 MIME-Version: 1.0 To: David Johnston CC: "pgsql-sql@postgresql.org" Subject: Re: advice on how to store variable attributes References: <4EA29DDB.9000300@linos.es> <00655F1E-08DC-42C5-B702-C8D332081557@yahoo.com> <4EA2E3A8.8090203@linos.es> <8B9FEA8A-D98D-4B5C-B957-2949A05DF9E6@yahoo.com> In-Reply-To: <8B9FEA8A-D98D-4B5C-B957-2949A05DF9E6@yahoo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201110/57 X-Sequence-Number: 35941 El 22/10/11 18:10, David Johnston escribió: > > > SELECT ... > FROM vendor_invoices > JOIN ( SELECT ... FROM eav WHERE category = '' ) icm USING ( invoice_id ) > > Add a sub-query join for each desired category. > > I agree HStore looks cleaner for the query example you give. One apparent advantage is that since each record contains a single value you can use additional columns to store properties (e.g. Units) whereas the hstore makes that more difficult - though not impossible - since the keys are bot naturally related to each other. > > From an output perspective hstore looks good. If there are no difficulties on the data input process you might as well just go with it. Given your volume and use-case it really isn't going to matter which option you pick; though I'd suggest providing views related to each major category with only the appropriate values and no access to the hstore column. > > David J. > > I will try with hstore and EAV both and see what seems more natural for me, i have to take account how easy/clean it is to work with both from the Qt application, i think eav would be much better to edit in a table. Thanks to all for the replies. Regards, Miguel Angel.