Re: implementation of a many-to-many relationship

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Dalton Shane <se401029(at)cs(dot)may(dot)ie>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: implementation of a many-to-many relationship
Date: 2002-02-27 15:11:21
Message-ID: 20020227070724.X2599-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 27 Feb 2002, Dalton Shane wrote:

> I need to implement a many-to-many relationship in PostgreSQL but don't know how
> to. I've trawled through the mailing lists but can't find anything, it's very
> easy to do in Access so it can't be that hard in PostgreSQL.
>
> I created a linking table between two tables (voter, candidates) called
> c_voting, I then reference the two table's primary keys to create a composite
> primary key for c_voting.
>
> However when I go to input data into c_voting I get a referential integrity
> error saying that the primary key of table voter doesn't match primary key of
> c_voting (which it shouldn't).

Are you sure that's what it said? I could see it saying something like
key referenced from c_voting not found in voter, but that'd make sense
if you were trying to insert a v_number that didn't exist in voter.

What version are you running? I tried the below in 7.2 and don't see
anything particularly wierd happening.
Can you give a sample set of inserts that you're trying and having fail?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dan Langille 2002-02-27 15:15:53 Re: implementation of a many-to-many relationship
Previous Message otisg 2002-02-27 14:18:49 Re: Err. compiling func. with SET TRANS...