Re: implementation of a many-to-many relationship
От | Dan Langille |
---|---|
Тема | Re: implementation of a many-to-many relationship |
Дата | |
Msg-id | 200202271515.g1RFFtk91244@lists.unixathome.org обсуждение исходный текст |
Ответ на | implementation of a many-to-many relationship (Dalton Shane <se401029@cs.may.ie>) |
Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: