From: Dan Langille <dan@langille.org>
To: Dalton Shane <se401029@cs.may.ie>
Cc: pgsql-sql@postgresql.org
Subject: Re: implementation of a many-to-many relationship
Date: Wed, 27 Feb 2002 10:15:53 -0500
Message-ID: <200202271515.g1RFFtk91244@lists.unixathome.org> (raw)
In-Reply-To: <200202271402.OAA23102@cs.may.ie>
On 27 Feb 2002 at 14:06, 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).
The actual error message would help us.
> I've tried everything I can think of for the last four days, but to no
> avail.
>
> This is a central part of my thesis and I need to get it working as soon as
> possible.
Yeah, well, we all have deadlines.
> If anyone knows how to implement this I would be very very very grateful,
> I've read all the documentation I can find but it didn't help.
>
> Many thanks in advance for any advice that you can offer.
I created your tables. Then executed the following commands:
test=# insert into voter (v_number) values (1);
INSERT 1067044 1
test=# insert into candidates (c_number) values (123);
INSERT 1067045 1
test=# insert into c_voting values (1, 123);
INSERT 1067046 1
test=# select * from c_voting;
v_number | c_number
----------+----------
1 | 123
(1 row)
I don't see the problem.
Perhaps you should supply your example which fails. Mentioning the
postgresql version might be helpful too. These tests were run on 7.2.
--
Dan Langille
The FreeBSD Diary - http://freebsddiary.org/ - practical examples
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: dan@langille.org, se401029@cs.may.ie
Subject: Re: implementation of a many-to-many relationship
In-Reply-To: <200202271515.g1RFFtk91244@lists.unixathome.org>
* 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