Re: N all-way relationship - Mailing list pgsql-sql

From Jamie Lawrence
Subject Re: N all-way relationship
Date
Msg-id 20030513172354.GV4093@jal.clueinc.net
Whole thread Raw
In response to N all-way relationship  ("Ryan" <pgsql-sql@seahat.com>)
List pgsql-sql
On Tue, 13 May 2003, Ryan wrote:

> I am trying to visualize the best way to store and retrieve information in
> a an all-way relationship with an unknown number of elements.
> So given a factory number of 123.
> if one vendor makes the part 456 that equates to 123, then, well that's
> quite easy.  You need a lookup table that corresponds 123 to 456, and for
> reverse lookups you store 456 - 123. (you have a whopping two records)

> You get the idea, you now have 20 records for five parts.  Now multiply
> that by the hundreds of thousands.  If another vendor added a compatable
> part, you just added 10 new records.
> 
> Now to the meat of my question.
> 
> Is there a better way to do this?

Why wouldn't you do a self reference for storing this?

create table ( id serial not null unique, partnum int, equiv_part int );

Your factory part number 123 goes in as, say (1, 123, NULL ).
All equivevalent parts go in as (2, 456, 1), (3, ABC, 1), etc.

Or am I missing something?

-j



-- 
Jamie Lawrence                                        jal@jal.org
"Every duck should aspire to be crispy and aromatic."   -sleepyhel



pgsql-sql by date:

Previous
From: David W Noon
Date:
Subject: Re: please help construct an SQL query
Next
From: Peter and Sarah Childs
Date:
Subject: Re: Constraint Syntax Question