pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Dalton Shane <se401029@cs.may.ie>
To: pgsql-sql@postgresql.org
Subject: Re: implementation of a many-to-many relationship
Date: Wed, 27 Feb 2002 08:25:01 -0800
Message-ID: <web-811711@davinci.ethosmedia.com> (raw)
In-Reply-To: <200202271402.OAA23102@cs.may.ie>

Dalton,

> 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.

No, it's not hard.  It's very basic, which is why it's not specifically
 documented in the PostgreSQL docs.

> 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.

This is correct.

> 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).

Can you please post your exact INSERT statements and error message?
  From my perusal, the problem is with how you are inserting the data,
 not your table design, which is fine (although I question your need
 for the DEFERRABLE & INITIALLY DEFERRED statements).

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



view thread (6+ messages)  latest in thread

Message-ID: <web-811711@davinci.ethosmedia.com>
Permalink:  ../web-811711@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-811711@davinci.ethosmedia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, se401029@cs.may.ie
  Subject: Re: implementation of a many-to-many relationship
  In-Reply-To: <web-811711@davinci.ethosmedia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox