Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iEg1D-0000vR-UA for pgsql-general@arkaria.postgresql.org; Sun, 29 Sep 2019 20:42:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iEg1B-0007a6-Gq for pgsql-general@arkaria.postgresql.org; Sun, 29 Sep 2019 20:42:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iEg1B-0007Z2-4m for pgsql-general@lists.postgresql.org; Sun, 29 Sep 2019 20:42:09 +0000 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iEg13-00048p-JK for pgsql-general@lists.postgresql.org; Sun, 29 Sep 2019 20:42:08 +0000 Received: by mail-io1-xd44.google.com with SMTP id v2so32461935iob.10 for ; Sun, 29 Sep 2019 13:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=XEICsYwP4WhmkQF1L3x9Bl4JyenGONIomlRgDnFYQ+0=; b=XFsEBUFPzwgcmcBbvVjUhUcE2W8ulijJpSYoQGfng/K+2O76ekLDskQuKQ6Rot0Tz0 4f4RHZPzNclSYbdVd3+HozZ2N5WEH9JPbWnJ/5HIRPiDviPYyLc3WIvHBKTGY8r3ZDSv xZ8/whmNv5rdVKi/7L0fjz6xpT5evpIeFBZTK2i7fho8RhWghjXkF5bg5N5z+/ptJ0ap mYMICMWMbQl2rPxAhsRBl0BhIVtmi/Df+YY9zxFFuoMC2f4fpuMzrhbKIFZzVcnRafZD TrfmZahdRHjCyo/Jk0I7nQkjBZi+YU6epSQILDnFKKeI6dRwE5sntGIXhYJAtOoGaIkF iw4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=XEICsYwP4WhmkQF1L3x9Bl4JyenGONIomlRgDnFYQ+0=; b=G5lRxQcwx3Tyu4Dl+tw85UZwaaLCSMEqb8g9PVab47o54JH1OEPuO9wo2xiH1Vkvmu RBIRpHfGceDQw9azxPifgqkVNwIzOhAqlgp5Pi1rBsdWpjq68veM8zomsqe/W+oQO8pb VYKIyEfWJDFWNl9rEKYkQivG1J+0pgNEkSl7Zco+ZpoesvHnj8e7CRoPU73Iz2EhFmUT uNzJ4A5Vj02ulPNz+LqacpIqxrid9lMNlZdkGZgx11564e9jZjRp9wVB5AUbxE+DvQdo z93LsRAOsvPNRxopKabgqjTtaKKRxQSpFMpDymPZPwjymzIfCELLqtIdXMKX8KkGDzge BACA== X-Gm-Message-State: APjAAAVyqqhe8wFRKuW3mhiXj/C5T8k9AI2mFrnHfOzrpNk5P7BrYqgS 5+l51SdLQ5T6uLFaJf68fw8= X-Google-Smtp-Source: APXvYqw3OvtvL8x4BFEXemMM9joRQOwdSUR06UQhVAj+9gAyJ5Ba2l7P87vYBpvEIPToNIJ9Pcfj+w== X-Received: by 2002:a5e:8c15:: with SMTP id n21mr17554438ioj.246.1569789719401; Sun, 29 Sep 2019 13:41:59 -0700 (PDT) Received: from [192.168.1.108] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id y16sm4052273ilp.37.2019.09.29.13.41.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Sep 2019 13:41:58 -0700 (PDT) From: Rob Sargent Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_3874C49D-7CFD-4C7B-A47C-D6E80B98C7A1" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Thoughts on a cosntraint ? Date: Sun, 29 Sep 2019 14:41:57 -0600 In-Reply-To: Cc: pgsql-general To: John W Higgins References: <20190929194020.GA16517@panix.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_3874C49D-7CFD-4C7B-A47C-D6E80B98C7A1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 29, 2019, at 1:52 PM, John W Higgins wrote: >=20 > On Sun, Sep 29, 2019 at 12:40 PM stan > wrote: > I have a table that consists of 3 columns. >=20 > vendor_key > mfg_key > preferred (boolean) >=20 > The idea is that a given vendor is the vendor we want to use for each > manufacturer for a given project. >=20 > I need to constrain such that only on row of mfg, vendor and project = can > be set to TRUE. >=20 >=20 > Partial unique index >=20 > Example 3 on this page = https://www.postgresql.org/docs/current/indexes-partial.html = is = exactly what you are looking for. >=20 > John W Higgins >=20 Yes but I have to wonder about one-and-only-one preferred vendor: if = there are many known, acceptable vendors, wouldn=E2=80=99t a ranking be = more useful? On a crucial commodity it is common practice to = continuously use more than one vendor (i.e. multiple preferred vendors). --Apple-Mail=_3874C49D-7CFD-4C7B-A47C-D6E80B98C7A1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Sep 29, 2019, at 1:52 PM, John W Higgins <wishdev@gmail.com> = wrote:

On Sun, Sep 29, 2019 at 12:40 PM = stan <stanb@panix.com> wrote:
I have a table that consists of = 3 columns.

vendor_key
mfg_key
preferred (boolean)

The idea is that a given vendor is the vendor we want to use for each
manufacturer for a given project.

I need to constrain such that  only on row of mfg, vendor and = project can
be set to TRUE.


Partial = unique index



Yes but I have to wonder about one-and-only-one = preferred vendor: if there are many known, acceptable vendors, = wouldn=E2=80=99t a ranking be more useful?  On a crucial commodity = it is common practice to continuously use more than one vendor (i.e. = multiple preferred vendors).


= --Apple-Mail=_3874C49D-7CFD-4C7B-A47C-D6E80B98C7A1--