Re: Primary and Foreign Key?

From: "Announce" <truthhurts(at)insightbb(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Primary and Foreign Key?
Date: 2005-09-24 14:55:20
Message-ID: KBEKKNMFLELKGIADDEPEAENPCAAA.truthhurts@insightbb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I think i found what i was looking for in the docs:

5.3.4. Primary Keys
Technically, a primary key constraint is simply a combination of a unique
constraint and a not-null constraint.

So i suppose i suppose i would use PRIKARY KEY(peopleid,groupid) to enforce
the UNIQUE NOT NULL constraint in one expression.

Thanks!
-----Original Message-----
From: Wayne Unruh [mailto:waynepunruh(at)hotmail(dot)com]
Sent: Saturday, September 24, 2005 1:46 AM
To: abanks(at)insightbb(dot)com; pgsql-novice(at)postgresql(dot)org
Subject: RE: [NOVICE] Primary and Foreign Key?

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
http://www.postgresql.org/docs/8.0/interactive/ddl-constraints.html

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:

PEOPLE
--------------
peopleid pkey,
name,
etc

GROUPS
-------------
groupid pkey,
description,
etc

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

Thanks!

--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 9/22/2005

--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.5/110 - Release Date: 9/22/2005

Browse pgsql-novice by date

  From Date Subject
Next Message A Gilmore 2005-09-24 19:11:09 View
Previous Message Oliver Elphick 2005-09-24 11:31:48 Re: Primary and Foreign Key?