Re: Multiway associations

From: Russell Shaw <rjshaw(at)iprimus(dot)com(dot)au>
To:
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Multiway associations
Date: 2004-01-25 05:23:29
Message-ID: 401352D1.8020602@iprimus.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Michael Glaesemann wrote:
> Hi Russel
>
> On Jan 25, 2004, at 12:46 PM, Russell Shaw wrote:
>
>> 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 common way to do this is to have three tables: one suppliers, one
> parts, and one suppliers-parts referencing suppliers and parts.

Hi,

> Does that help?

Maybe so. I thought of this and was wondering if it was the common solution.
Should it be something like:

spid supplier part
---------------------
0 sid_1 pid_1
1 sid_1 pid_2
2 sid_2 pid_2
3 sid_3 pid_3
4 sid_3 pid_1
...

Ie, the third table just stores all the combinations of parts and suppliers?

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Glaesemann 2004-01-25 06:33:21 Re: Multiway associations
Previous Message Bruce Momjian 2004-01-25 05:19:27 Re: Problem with pg_hba.conf file in Postgres 7.3