X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3DEAC474E42 for ; Tue, 13 May 2003 12:24:39 -0400 (EDT) Received: from jal.clueinc.net (xd84b436b.ip.e-nt.net [216.75.67.107]) by postgresql.org (Postfix) with ESMTP id 161C84763AF for ; Tue, 13 May 2003 12:24:08 -0400 (EDT) Received: from jal.clueinc.net (localhost [127.0.0.1]) by jal.clueinc.net (8.12.9/8.12.9/Debian-3) with ESMTP id h4DHNsIE021539 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 13 May 2003 12:23:55 -0500 Received: (from jal@localhost) by jal.clueinc.net (8.12.9/8.12.9/Debian-3) id h4DHNsBB021537; Tue, 13 May 2003 12:23:54 -0500 Date: Tue, 13 May 2003 12:23:54 -0500 From: Jamie Lawrence To: Ryan Cc: pgsql-sql@postgresql.org Subject: Re: N all-way relationship Message-ID: <20030513172354.GV4093@jal.clueinc.net> Mail-Followup-To: Ryan , pgsql-sql@postgresql.org References: <11523.65.102.128.233.1052835391.squirrel@fordparts.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11523.65.102.128.233.1052835391.squirrel@fordparts.com> Organization: clue inc X-URL: http://www.clueinc.net/ User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/266 X-Sequence-Number: 13431 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