Re: implementation of a many-to-many relationship

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: implementation of a many-to-many relationship
Дата
Msg-id web-811711@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на implementation of a many-to-many relationship  (Dalton Shane <se401029@cs.may.ie>)
Список pgsql-sql
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 specificallydocumented 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
insertingthe data,not your table design, which is fine (although I question your needfor the DEFERRABLE & INITIALLY
DEFERREDstatements).
 

-Josh

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


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Dan Langille"
Дата:
Сообщение: Re: implementation of a many-to-many relationship
Следующее
От: "Samuel J. Sutjiono"
Дата:
Сообщение: System Messages