Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UXF9F-0005bB-5G for pgsql-sql@arkaria.postgresql.org; Tue, 30 Apr 2013 18:19:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UXF9E-0005kY-Ki for pgsql-sql@arkaria.postgresql.org; Tue, 30 Apr 2013 18:19:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UXF9D-0005kS-No for pgsql-sql@postgresql.org; Tue, 30 Apr 2013 18:19:27 +0000 Received: from mout.gmx.net ([212.227.15.19]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UXF9A-0004Ms-RC for pgsql-sql@postgresql.org; Tue, 30 Apr 2013 18:19:27 +0000 Received: from mailout-de.gmx.net ([10.1.76.24]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0MJ0dz-1UZhz82dZ3-002UlX for ; Tue, 30 Apr 2013 20:19:23 +0200 Received: (qmail invoked by alias); 30 Apr 2013 18:19:23 -0000 Received: from p5082D1AD.dip0.t-ipconnect.de (EHLO GK1C06) [80.130.209.173] by mail.gmx.net (mp024) with SMTP; 30 Apr 2013 20:19:23 +0200 X-Authenticated: #41312857 X-Provags-ID: V01U2FsdGVkX1++Ou1SRqG+Qq/y1jhdmyvseYiH6Gp2wLanI9z+C3 IOzAhHqJMLvz8C Date: Tue, 30 Apr 2013 20:19:22 +0200 From: Wolfgang Keller To: pgsql-sql@postgresql.org Subject: Re: Correct implementation of 1:n relationship with n>0? Message-Id: <20130430201922.be3c8b2294ccbf48fbff362f@gmx.net> In-Reply-To: <20130430163905.77d43412c0176c3d9ebd8d90@gmx.net> References: <20130430163905.77d43412c0176c3d9ebd8d90@gmx.net> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.10.14; i686-pc-mingw32) Mail-Copies-To: never Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -4.4 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org > It hit me today that a 1:n relationship can't be implemented just by a > single foreign key constraint if n>0. I must have been sleeping very > deeply not to notice this. > > E.g. if there is a table "list" and another table "list_item" and the > relationship can be described as "every list has at least one > list_item" (and every list_item can only be part of one list, but > this is trivial). BTW: If every list_item could be part of any number (>0) of lists, you get a n:m relationship with a join table and then the issue that each list_item has to belong to at least one list arises as well. Maybe there should also be a standard solution documented somewhere for this case, too. Sincerely, Wolfgang -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql