Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 9AA9DB5DBDE for ; Thu, 19 May 2011 17:17:19 -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 40265-05 for ; Thu, 19 May 2011 20:17:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gy0-f174.google.com (mail-gy0-f174.google.com [209.85.160.174]) by mail.postgresql.org (Postfix) with ESMTP id 8FC20B5DBC1 for ; Thu, 19 May 2011 17:17:11 -0300 (ADT) Received: by gyd10 with SMTP id 10so1069714gyd.19 for ; Thu, 19 May 2011 13:17:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=sKa9GIYiF5cbW6eK2Kaj/vSHr8QQXOdt3lqsNFuup2w=; b=wx0JI4+R+kh778E8nVPUzs3b6V9fSgi0fpoIv28dtw5ErDfxVxevcSDcG5DEXype1L crCDU1ly/hSlE2K2KmJNuNmseJkR7U4rHZj73HZc5Ju3vOQ8LJ4BC4MgWqfshe9cNm99 rDGJPklGWWKs1x4kQ9T+HzfXhLm+I4iNp7dSM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=XY8Tbq/C5AN7Fmf9WM9TUJ6EQELzcGHl+lvwg6hagUKEG3PUhfw7m6gqvOYBIoHIhu 4yGkWYqG3x5jYwpSj0WQ7pDTzDZ/E4Rk/VgmyAYOZK70LPW+iocIt+5seCK3VkESFdrh BVrPGO46wu2rf5lZamSJFDcJvldk8B9E//obY= MIME-Version: 1.0 Received: by 10.236.161.131 with SMTP id w3mr4119554yhk.5.1305836230825; Thu, 19 May 2011 13:17:10 -0700 (PDT) Received: by 10.236.105.180 with HTTP; Thu, 19 May 2011 13:17:10 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 May 2011 16:17:10 -0400 Message-ID: Subject: Re: 5.3.5. Foreign Keys (The SQL Language) possible enhance From: Robert Haas To: Grzegorz Szpetkowski Cc: pgsql-docs@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/57 X-Sequence-Number: 6732 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-CONSTR= AINTS-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 ( > =A0 =A0order_id integer PRIMARY KEY, > =A0 =A0product_no integer REFERENCES products (product_no) NOT NULL, > =A0 =A0quantity integer > ); I don't think we should change the example, but we could probably clarify the wording. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company