Re: Lookup tables - Mailing list pgsql-general

From David G. Johnston
Subject Re: Lookup tables
Date
Msg-id CAKFQuwbhX=61U3nBgrx7483JcGyvuep6sVNYbQ=euo7V0S0wYA@mail.gmail.com
Whole thread Raw
In response to Re: Lookup tables  (Ron Johnson <ronljohnsonjr@gmail.com>)
Responses Re: Lookup tables
List pgsql-general
On Tuesday, February 4, 2025, Ron Johnson <ronljohnsonjr@gmail.com> wrote:
On Tue, Feb 4, 2025 at 9:41 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tuesday, February 4, 2025, Rich Shepard <rshepard@appl-ecosys.com> wrote:
Should lookup tables have a numeric FK column as well as the description column?

If so, how should I add an FK to the two lookup tables in my database?

Most do (have a surrogate PK) since it removes cascading updates
 
How does a synthetic PK "remove cascading updates"?  Doesn't the decision on whether or not to cascade update depend on the ON UPDATE CASCADE clause of the FK definition?


People don’t change synthetic PKs so updates never have to happen on the FK side.  Labels do get changed, in which case you have to update the FK label side.

David J.
 

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Lookup tables
Next
From: Ron Johnson
Date:
Subject: Re: Lookup tables