Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id AC0F4B5DBFB for ; Wed, 12 Oct 2011 17:59:09 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 57731-01-4 for ; Wed, 12 Oct 2011 20:59:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id CBA24B5DBF4 for ; Wed, 12 Oct 2011 17:59:02 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p9CKx4K06548; Wed, 12 Oct 2011 16:59:04 -0400 (EDT) From: Bruce Momjian Message-Id: <201110122059.p9CKx4K06548@momjian.us> Subject: Re: 5.3.5. Foreign Keys (The SQL Language) possible enhance In-Reply-To: To: Robert Haas Date: Wed, 12 Oct 2011 16:59:04 -0400 (EDT) CC: Grzegorz Szpetkowski , pgsql-docs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ELM1318453144-1529-5_" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/38 X-Sequence-Number: 7038 --ELM1318453144-1529-5_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Robert Haas wrote: > On Fri, May 6, 2011 at 9:50 PM, Grzegorz Szpetkowski > wrote: > > I have some remark about > > > > "Now it is impossible to create orders with product_no entries that do > > not appear in the products table." > > > > http://www.postgresql.org/docs/9.0/static/ddl-constraints.html#DDL-CONSTRAINTS-FK > [...] > > > > There is still possibility to add product_no (exactly NULL) value, > > which does not appear (cannot because of primary key nature) in > > products table. To get "full solution" you need create orders table as > > > > CREATE TABLE orders ( > > ? ?order_id integer PRIMARY KEY, > > ? ?product_no integer REFERENCES products (product_no) NOT NULL, > > ? ?quantity integer > > ); > > I don't think we should change the example, but we could probably > clarify the wording. Done with the attached patch. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --ELM1318453144-1529-5_ Content-Transfer-Encoding: 7bit Content-Type: text/x-diff Content-Disposition: inline; filename="/rtmp/null" diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml new file mode 100644 index c624fc2..ea840fb *** a/doc/src/sgml/ddl.sgml --- b/doc/src/sgml/ddl.sgml *************** CREATE TABLE orders ( *** 688,694 **** quantity integer ); ! Now it is impossible to create orders with product_no entries that do not appear in the products table. --- 688,694 ---- quantity integer ); ! Now it is impossible to create orders with non-NULL product_no entries that do not appear in the products table. --ELM1318453144-1529-5_--