Re: N all-way relationship

From: Jamie Lawrence <pgsql-sql(at)jal(dot)org>
To: Ryan <pgsql-sql(at)seahat(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: N all-way relationship
Date: 2003-05-13 17:23:54
Message-ID: 20030513172354.GV4093@jal.clueinc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)jal(dot)org
"Every duck should aspire to be crispy and aromatic."
-sleepyhel

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Adam Sherman 2003-05-13 17:46:50 Re: Locating all Children given Set of Parents
Previous Message jwang 2003-05-13 17:18:52 insert problem with special characters