From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | maweki(at)gmail(dot)com |
Cc: | pgsql-docs(at)lists(dot)postgresql(dot)org |
Subject: | Re: Foreign Keys being able to reference same table not spelled out in documentation |
Date: | 2021-04-29 17:32:59 |
Message-ID: | 3084939.1619717579@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
PG Doc comments form <noreply(at)postgresql(dot)org> writes:
> In Section 5.4.5 of the documentation regarding Foreign Key Constraints it
> is stated
> "A foreign key constraint specifies that the values [...] must match the
> values appearing in some row of another table."
> But referencing the same table is allowed and necessary for tree-like
> structures.
Fair point, and I notice that the term "self-referential foreign key"
appears nowhere in our docs, which seems like an oversight. However,
I think changing this first introductory sentence to something like
"the same or another table" would be a mistake. It would confuse
novices' mental model of what's happening, in service of a relatively
seldom-used corner case.
I'm inclined to propose adding an example a little further down, as
per the attached draft patch. This wouldn't help people who stop
reading after the section's first sentence, but we can't cover
everything in the first sentence.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
document-self-referential-FKs.patch | text/x-diff | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | tanghy.fnst@fujitsu.com | 2021-04-30 03:23:28 | [DOC] pg_stat_replication_slots representation style inconsisitant |
Previous Message | Tom Lane | 2021-04-29 14:31:43 | Re: pl/pgsql errors when multi-dimensional arrays are used |