X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A37EF52A8B for ; Mon, 7 Mar 2005 18:41:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65872-08 for ; Mon, 7 Mar 2005 18:41:11 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 37DE352A7A for ; Mon, 7 Mar 2005 18:41:10 +0000 (GMT) Received: (qmail 12162 invoked from network); 7 Mar 2005 19:41:57 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 7 Mar 2005 19:41:57 +0100 To: "Bruno Wolff III" Cc: "Stefan Weiss" , pgsql-sql@postgresql.org Subject: Re: Links between rows in a table References: <422A8A26.1070704@foo.at> <20050306174201.GA19019@wolff.to> <422B4B9A.8020606@foo.at> <20050307161555.GA3643@wolff.to> Message-ID: Date: Mon, 07 Mar 2005 19:41:25 +0100 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <20050307161555.GA3643@wolff.to> User-Agent: Opera M2/7.54u1 (Linux, build 892) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/112 X-Sequence-Number: 20591 > The trouble with this approach is that for some ways of using this data > you will need to worry about the ordering of of the values. Tradeoffs, always tradeoffs... It depends on the application. Note also that it eliminates duplicates ; moreover without such a condition, any relation A-B could have the rows [(A,B)] or [(B,A)] or [(A,B),(B,A)] which promises to cause headaches if you need to get rid of the duplicates... I used this scheme for an "also purchased products" thingy on a website, it works well. In this case the row must be unique because we have (A,B,count) which is the number of times products A and B have been purchased together, in this case having rows (B,A) and (A,B) separated wouldn't help in sorting by this count, which is in my case very fast thanks to a multicolumn index. > Note that you can't literally use 'min' and 'max' as above, as those > functions > don't do that. You could use 'case' to do that. ... yes, it was just a way of saying it. You can define functions that take integers as arguments (I wish these basic bricks were defined by default)... > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >