pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@boutiquenumerique.com>
To: Bruno Wolff III <bruno@wolff.to>
Cc: Stefan Weiss <spaceman@foo.at>
Cc: pgsql-sql@postgresql.org
Subject: Re: Links between rows in a table
Date: Mon, 07 Mar 2005 19:41:25 +0100
Message-ID: <opsm957bpsth1vuj@musicbox> (raw)
In-Reply-To: <20050307161555.GA3643@wolff.to>
References: <422A8A26.1070704@foo.at>
	<20050306174201.GA19019@wolff.to>
	<422B4B9A.8020606@foo.at>
	<opsm8dm0z7th1vuj@musicbox>
	<20050307161555.GA3643@wolff.to>


> 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
>





view thread (7+ messages)

Message-ID: <opsm957bpsth1vuj@musicbox>
Permalink:  ../opsm957bpsth1vuj@musicbox/
Also on:    postgresql.org/message-id/opsm957bpsth1vuj@musicbox

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lists@boutiquenumerique.com, bruno@wolff.to, spaceman@foo.at
  Subject: Re: Links between rows in a table
  In-Reply-To: <opsm957bpsth1vuj@musicbox>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox