Skip site navigation (1) Skip section navigation (2)

Re: Primary and Foreign Key?

From: "Wayne Unruh" <waynepunruh(at)hotmail(dot)com>
To: abanks(at)insightbb(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: Primary and Foreign Key?
Date: 2005-09-24 06:45:45
Message-ID: BAY106-F12E52354080C494806E050AF890@phx.gbl (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
In relational databases  A table can have at most one primary key.  However, 
you are not required to have a primary key, so I would just have the two 
foreign keys in the table PEOPLEGROUPS.

For more information on Constraints see

Wayne Unruh

From : 	A. Banks <abanks(at)insightbb(dot)com>
Sent : 	Wednesday, September 21, 2005 8:46 PM
To : 	<pgsql-novice(at)postgresql(dot)org>
Subject : 	[NOVICE] Primary and Foreign Key?

I have the following related tables:

peopleid pkey,

groupid pkey,

peopleid pkey/fkey,
groupid pkey/fkey

What is the CORRECT way (in Postgres) to define the PEOPLEGROUPS table so
that it has both the double primary key AND still acts as a foreign key for
people.peopleid and groups.groupid? Can i specify both or is this not
necessary? Any suggestions would be appreciated.


In response to

pgsql-novice by date

Next:From: Oliver ElphickDate: 2005-09-24 11:31:48
Subject: Re: Primary and Foreign Key?
Previous:From: Lane Van IngenDate: 2005-09-23 20:17:04
Subject: Re: Init script

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group