pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jamie Lawrence <pgsql-sql@jal.org>
To: Ryan <pgsql-sql@seahat.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: N all-way relationship
Date: Tue, 13 May 2003 12:23:54 -0500
Message-ID: <20030513172354.GV4093@jal.clueinc.net> (raw)
In-Reply-To: <11523.65.102.128.233.1052835391.squirrel@fordparts.com>
References: <11523.65.102.128.233.1052835391.squirrel@fordparts.com>


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




view thread (4+ messages)

Message-ID: <20030513172354.GV4093@jal.clueinc.net>
Permalink:  ../20030513172354.GV4093@jal.clueinc.net/
Also on:    postgresql.org/message-id/20030513172354.GV4093@jal.clueinc.net

 · 

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: pgsql-sql@jal.org, pgsql-sql@seahat.com
  Subject: Re: N all-way relationship
  In-Reply-To: <20030513172354.GV4093@jal.clueinc.net>

* 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