Re: N all-way relationship

Поиск
Список
Период
Сортировка
От Jamie Lawrence
Тема Re: N all-way relationship
Дата
Msg-id 20030513172354.GV4093@jal.clueinc.net
обсуждение исходный текст
Ответ на N all-way relationship  ("Ryan" <pgsql-sql@seahat.com>)
Список 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 по дате отправления:

Предыдущее
От: David W Noon
Дата:
Сообщение: Re: please help construct an SQL query
Следующее
От: Peter and Sarah Childs
Дата:
Сообщение: Re: Constraint Syntax Question