Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lebdg-0000iu-F1 for pgsql-docs@arkaria.postgresql.org; Thu, 06 May 2021 10:53:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lebdf-00004u-Bk for pgsql-docs@arkaria.postgresql.org; Thu, 06 May 2021 10:53:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1leXAr-0004Kt-7j for pgsql-docs@lists.postgresql.org; Thu, 06 May 2021 06:07:49 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1leXAm-0008W6-4d for pgsql-docs@lists.postgresql.org; Thu, 06 May 2021 06:07:48 +0000 Received: by mail-wm1-x32e.google.com with SMTP id s82so2659258wmf.3 for ; Wed, 05 May 2021 23:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=yOVy63V9BnyftOUHIsJocczNyJI1GqKMhehKMwGHmGo=; b=LqlSAx7mHaq4KVswukjm5aZRT7pSLx/ZXdqB+yhcK+jZ375ZLftokRJlrcww6mnLEC 6PHgCGcWFJSToQAuv2kvka1pyUMyU7PbXGjZk93XaOHlYzJSCCd/DV3k2q1wnegTZVCU l6yYe71n2UPw+qIQjBwMBcl+cHbtqZs+ZW0r5h3ZBOtgJJ6MuIW8mRR6QWa1J22zdqVM M38jDNlk66omamwS8+pEA6PX5wXxRgDDHtBTLN6n30mPgogZ6CJ5ctA9JJCm+3DpeHu4 5TCiZi4zkcSPZcQu7EydmxbyPpIu4ruRjZtKFiZS8i6UfwQiGYHOICX1Fw8NFsyByCTV /flw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=yOVy63V9BnyftOUHIsJocczNyJI1GqKMhehKMwGHmGo=; b=E9wdQX2jYNOEINxRsQKGiMUZAAmQMKrHstijApEBPp5hzz+sAVP0PI5pMdfDyuuYuk JLv5F8vvvFlskWTHLvbcA4YdOCmpfjKImM1fsbwEWymwjlAYPyi08ab7dNndOi6coaCS saLyHCtZt+6XsdKnALHYnhTavmNReZsrbx3q7m15EnFwCT8L5BsP3z31giouXNz87hNz M/CfFDYDZkVPT4hrVrrJWmGP3/cY5D62/gaU8Paqki/F+/htV+iBD2yqjJoSIdrwRWfX 0A5lJyVg6X2DUcE1Aqoa7feQtrTli8+RLN611QQIFmHWMl+aJGjM60xpApOaC/ErLYP9 KxZQ== X-Gm-Message-State: AOAM530qq04FFqB+lNc6EFgCWY86Pb4vwvllfyxmRjSgdMtcmAlN/Cxj tDx6Jp13NyDOHMv/AaFspsc= X-Google-Smtp-Source: ABdhPJwTIAHHDoKNxDVbZBH4rfz+cY9huEjdQl2lJz0jP0Jpocw2DQH3dJH4PVMGlfm+vCYJAeR9rw== X-Received: by 2002:a7b:c405:: with SMTP id k5mr13260526wmi.93.1620281261301; Wed, 05 May 2021 23:07:41 -0700 (PDT) Received: from [192.168.1.123] (dslb-084-058-091-053.084.058.pools.vodafone-ip.de. [84.58.91.53]) by smtp.gmail.com with ESMTPSA id q10sm1922597wmc.31.2021.05.05.23.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 23:07:40 -0700 (PDT) Message-ID: Subject: Re: Foreign Keys being able to reference same table not spelled out in documentation From: maweki@gmail.com To: "David G. Johnston" , Tom Lane Cc: Pg Docs Date: Thu, 06 May 2021 08:07:39 +0200 In-Reply-To: References: <161969805833.690.13680986983883602407@wrigleys.postgresql.org> <3084939.1619717579@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.0 (3.40.0-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Note that it is in general not necessary for the referencing column to be NULLABLE. If you defer the constraint checking, you can insert a cyclic structure. Of course, it's no longer a tree then. The tutorial-ness of the documentation was already pointed out and I don't think it needs to be said there. We just would want to not imply this (nullable) would be necessary. Documentation-wise I liked to MariaDB approach very much, where the two tables were named "parent table" and "child table" and at some point you note that it is allowed for a table to be both. But this would be a lot more invasive. All the Best Mario Wenzel Am Mittwoch, dem 05.05.2021 um 21:17 -0700 schrieb David G. Johnston: > On Thu, Apr 29, 2021 at 10:33 AM Tom Lane wrote: > > 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. > > > > > > > Given the tutorial nature of this section I agree with the approach. > > I did a read through of the patch and I like it; though I suggest > changing "but non-NULL" to "while non-NULL". > > Thanks! > > David J. >