Re: Primary key question - Mailing list pgsql-general

From Ruediger Maehl
Subject Re: Primary key question
Date
Msg-id newscache$b3s5xf$ldf$1@www
Whole thread Raw
List pgsql-general
Hi Richard,

Richard Rowell schrieb in Nachricht
<3bi0ms00iak74c6jm26117unsskokmp0b4@4ax.com>...
>I'm creating a database with 20 tables or so.  I have come to the
>table that will likely tie many of these tables together, that is
>every single field in this table will be a foriegn key.  My question
>is, rather then include all of the fields into the primary key of this
>table, and therefore include all of these fields into any table that
>will reference this one, would it be politically correct to just give
>each entry an integer as a primary key

it is not only politically but also absolutely correct
to use one expression as primary key for table that
is mostly or even only composed of foreign keys to
other tables.


> and scan for dupes in a trigger?

You can create a unique index on a combination of columns
to prevent duplicate entries.

> It sure seems like it would cut down on the complexity of
>the whole thing...

yep

>
>Thanx in advance!

Ruediger



pgsql-general by date:

Previous
From: "Stephen Lawrence"
Date:
Subject: Can't unsubscribe
Next
From: Jeroen Ruigrok/Asmodai
Date:
Subject: Re: [ANNOUNCE] Re: [HACKERS] proposed improvements to PostgreSQL license