Re: Multiway associations

From: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
To: "pgsql-general (at) postgresql (dot) org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multiway associations
Date: 2004-01-25 10:34:57
Message-ID: 20040125103457.A22981@bacon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 |
+------------------------------+---------------------------------------------+

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2004-01-25 10:36:33 Re: OT: SCO Extortion
Previous Message Chris Travers 2004-01-25 07:05:07 Re: OT: SCO Extortion