Re: [GENERAL] Sufficient Primary Key? - Mailing list pgsql-general

From James Olin Oden
Subject Re: [GENERAL] Sufficient Primary Key?
Date
Msg-id 81Jul23.130839edt.35713@gateway.lee.k12.nc.us
Whole thread Raw
In response to Re: [GENERAL] Sufficient Primary Key?  (Dan Delaney <dionysos@dionysia.org>)
List pgsql-general
>
>
> I don't like doing that because I don't want to store the entire
> name in every other table which needs to be linked with this one.
> So, for instance, in the table that keeps track of what authors go
> to what book, I want it to just have two fields, the Book's primary
> key and the Author's primary key, and I'd prefer those primary keys
> to be nice and small instead of, say, the entire title and copyright
> year for the book and the entire first and last name and date of
> birth for the author. See what I mean?
>

Here is a suggestion.  Create a table that has an int4 as the key.  Cause this
value to be auto incremented based off of a sequence each time an insert is
done to it.  The other fields would include the actuall lookup infromation
(i.e. their first and last name, and the code you wanted to append to that).
Now in all your tables use the int4 key to reference the lookup.  Once you do
this, on all your forms that look up information based off of this first and
last name and the other value, you can have them type just that, and then you
can do a query that looks in the table to find the int4 key, and then use that
value to find the actual record for which you are looking.  This schema will
totally get rid of the need to concern yourself with making the lookup
information "unique", because if it is not unique your query would simply
return multiple records (hopefully only two or three) from which the user can
choose.

I hope this helps...james


> > BTW, Alan Watts is a favourite of mine.
>
> Mine too.
>
>  --Dan
>
> -----------------------------------------------------------------------
>  Daniel G. Delaney                    The Louisville Times Chorus
>  Dionysos@Dionysia.org                   www.LouisvilleTimes.org
>  www.Dionysia.org/~dionysos/          Dionysia Design
>  ICQ Number: 8171285                     www.Dionysia.com/design/
> -----------------------------------------------------------------------
>                    I doubt, therefore I might be.




pgsql-general by date:

Previous
From: Steve Doliov
Date:
Subject: Re: [GENERAL] Re: [HACKERS] [Fwd: SGVLLUG Oracle and Informix on Linux]
Next
From: lynch@lscorp.com (Richard Lynch)
Date:
Subject: Re: [GENERAL] Re: [INTERFACES] ODBC Driver -- Access Order By problem solved!!!