Re: Multiway associations - Mailing list pgsql-general

From Paul Thomas
Subject Re: Multiway associations
Date
Msg-id 20040125103457.A22981@bacon
Whole thread Raw
In response to Multiway associations  (Russell Shaw <rjshaw@iprimus.com.au>)
List pgsql-general
On 25/01/2004 05:06 Russell Shaw wrote:
> Hi,
> I'm making my first database.
>
> I have a list of parts, each of which is sold by multiple
> vendors. I also have a list of vendors, each of which sell
> multiple parts.
>
> How should i arrange the tables for this that doesn't involve
> having lots of empty fields "just in case" ?


One way would be to have a separate vendorpart table something like

CREATE TABLE vendorpart
(
   vendor_id      int4,
   part_id        int4
);

which holds the relationships. You'll to define indexes, contraints and
foreign keys on it.
--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

pgsql-general by date:

Previous
From: "Chris Travers"
Date:
Subject: Re: OT: SCO Extortion
Next
From: "Chris Travers"
Date:
Subject: Re: OT: SCO Extortion