Re: Links between rows in a table

From: PFC <lists(at)boutiquenumerique(dot)com>
To: "Bruno Wolff III" <bruno(at)wolff(dot)to>
Cc: "Stefan Weiss" <spaceman(at)foo(dot)at>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Links between rows in a table
Date: 2005-03-07 18:41:25
Message-ID: opsm957bpsth1vuj@musicbox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Henry Ortega 2005-03-07 21:38:53 drop view even with dependencies?
Previous Message KÖPFERL Robert 2005-03-07 18:20:56 Lambda expressions in SQL