Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wD1b4-002Wzr-0Q for pgsql-docs@arkaria.postgresql.org; Wed, 15 Apr 2026 14:52:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wD1b3-0004FU-1P for pgsql-docs@arkaria.postgresql.org; Wed, 15 Apr 2026 14:52:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wCbdi-00BTn3-2z for pgsql-docs@lists.postgresql.org; Tue, 14 Apr 2026 11:09:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wCbdh-000000010rc-0sGK for pgsql-docs@lists.postgresql.org; Tue, 14 Apr 2026 11:09:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=3Sp7YbRsHd1HREepTilj30gt5PJnY0jlM3lmoSlq284=; b=glItaZux6z5ym9wMkXZCJIShj1 Kw9di93txCnnrOy1FCtZInWyEBW1oDJgLlHbUwVIrkHwO8O5FYMLHG/6XYhaWLLd+cCjUaTj5zHMM p5vjMQx4B7iGxJPsYXEqj4hjQ/rMpHIEpVhYkdU1/rV8YyqLyHDHfokPwmSg2evQmisUkdluHiCso u7IuBF2YZsViX1SFGDO3oGgM1UuBZZYd8GvTr5o67EkTLAu2acg89LdzZ+jaxBGqdcl3m1KY4V9oj 6VtrzHEWHTyG+9alR0HyZTAZFmwHIrBz/ySkz0BiFwR0Akvt6Rd8kvtdmow1yDMC1BD/X927rQFdn 74yXpjNg==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wCbdf-002pue-11 for pgsql-docs@lists.postgresql.org; Tue, 14 Apr 2026 11:09:03 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wCbde-00604h-0Z for pgsql-docs@lists.postgresql.org; Tue, 14 Apr 2026 11:09:02 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Example. Foreign Keys Constraints. Wrong Columns To: pgsql-docs@lists.postgresql.org From: PG Doc comments form Cc: postgresql.org.reach457@passmail.net Reply-To: postgresql.org.reach457@passmail.net, pgsql-docs@lists.postgresql.org Date: Tue, 14 Apr 2026 11:08:35 +0000 Message-ID: <177616491576.403057.11334419722719232554@wrigleys.postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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-CONSTRAINT= S-FK In the last example of this section it seems the `users` table is referenced wrong. ```sql CREATE TABLE users ( tenant_id integer REFERENCES tenants ON DELETE CASCADE, user_id integer NOT NULL, PRIMARY KEY (tenant_id, user_id) ); CREATE TABLE posts ( tenant_id integer REFERENCES tenants ON DELETE CASCADE, post_id integer NOT NULL, author_id integer, PRIMARY KEY (tenant_id, post_id), FOREIGN KEY (tenant_id, author_id) REFERENCES users ON DELETE SET NULL (author_id) ); ``` In this example `FOREIGN KEY (tenant_id, author_id) REFERENCES users ON DELETE SET NULL (author_id)` implies that `users` table columns are named `(tenant_id, author_id)` but in fact `users` table does not have a `author_id` column. That line should be probably like this because `users` tables has a `user_id` column instead of `author_id` ```sql CREATE TABLE posts ( # ... FOREIGN KEY (tenant_id, author_id) REFERENCES users (tenant_id, user_id) ON DELETE SET NULL (author_id) ); ```