From: Rob Sargent <robjsargent@gmail.com>
To: John W Higgins <wishdev@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Thoughts on a cosntraint ?
Date: Sun, 29 Sep 2019 14:41:57 -0600
Message-ID: <F01FBE40-A1DD-49B7-9C73-7ECA4F987E76@gmail.com> (raw)
In-Reply-To: <CAPhAwGz17hBnKdnMoZZAx=9Edkn5ih2rzJFEhQhGx+vopnWrCQ@mail.gmail.com>
References: <20190929194020.GA16517@panix.com>
<CAPhAwGz17hBnKdnMoZZAx=9Edkn5ih2rzJFEhQhGx+vopnWrCQ@mail.gmail.com>
> 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 <mailto: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
>
> Example 3 on this page https://www.postgresql.org/docs/current/indexes-partial.html <https://www.postgresql.org/docs/current/indexes-partial.html; is exactly what you are looking for.
>
> John W Higgins
>
Yes but I have to wonder about one-and-only-one preferred vendor: if there are many known, acceptable vendors, wouldn’t 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).
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com, wishdev@gmail.com
Subject: Re: Thoughts on a cosntraint ?
In-Reply-To: <F01FBE40-A1DD-49B7-9C73-7ECA4F987E76@gmail.com>
References: <20190929194020.GA16517@panix.com> <CAPhAwGz17hBnKdnMoZZAx=9Edkn5ih2rzJFEhQhGx+vopnWrCQ@mail.gmail.com> <F01FBE40-A1DD-49B7-9C73-7ECA4F987E76@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox