public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: [email protected]
To: [email protected]
Subject: Re: Example. Foreign Keys Constraints. Wrong Columns
Date: Wed, 15 Apr 2026 08:23:34 -0700
Message-ID: <CAKFQuwbm4BD49A8ZqjZnxHKW8MsEURa6hrEvAWKxw0_nu=FZwg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On Wed, Apr 15, 2026 at 7:51 AM PG Doc comments form <[email protected]>
wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/18/ddl-constraints.html
> Description:
>
>
> https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK
>
>
Given that users has:

>     PRIMARY KEY (tenant_id, user_id)
>
>
This:


>     FOREIGN KEY (tenant_id, author_id) REFERENCES users ON DELETE SET NULL
> (author_id)
>
>
And this:


>     FOREIGN KEY (tenant_id, author_id) REFERENCES users (tenant_id,
> user_id)
> ON DELETE SET NULL (author_id)
>

Produce an identical outcome.

The absence of a column list on the former causes the system to look at the
primary key for the named table and use its column list - which is
(tenant_id, user_id), same as the later explicit version.

David J.


view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Example. Foreign Keys Constraints. Wrong Columns
  In-Reply-To: <CAKFQuwbm4BD49A8ZqjZnxHKW8MsEURa6hrEvAWKxw0_nu=FZwg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox