pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedThoughts on a cosntraint ?
4+ messages / 4 participants
[nested] [flat]
* Thoughts on a cosntraint ?
@ 2019-09-29 19:40 stan <stanb@panix.com>
0 siblings, 2 replies; 4+ messages in thread
From: stan @ 2019-09-29 19:40 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
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.
I would be interested in seeing other peoples approaches on this, also.
Any thoughts?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Thoughts on a cosntraint ?
@ 2019-09-29 19:52 John W Higgins <wishdev@gmail.com>
parent: stan <stanb@panix.com>
1 sibling, 1 reply; 4+ messages in thread
From: John W Higgins @ 2019-09-29 19:52 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
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
Example 3 on this page
https://www.postgresql.org/docs/current/indexes-partial.html is exactly
what you are looking for.
John W Higgins
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Thoughts on a cosntraint ?
@ 2019-09-29 20:41 Rob Sargent <robjsargent@gmail.com>
parent: John W Higgins <wishdev@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Rob Sargent @ 2019-09-29 20:41 UTC (permalink / raw)
To: John W Higgins <wishdev@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
> 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).
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Thoughts on a cosntraint ?
@ 2019-09-29 21:16 Adrian Klaver <adrian.klaver@aklaver.com>
parent: stan <stanb@panix.com>
1 sibling, 0 replies; 4+ messages in thread
From: Adrian Klaver @ 2019-09-29 21:16 UTC (permalink / raw)
To: stan <stanb@panix.com>; pgsql-general@lists.postgresql.org
On 9/29/19 12:40 PM, stan 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.
Where is the project id?
>
> I would be interested in seeing other peoples approaches on this, also.
>
> Any thoughts?
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2019-09-29 21:16 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-09-29 19:40 Thoughts on a cosntraint ? stan <stanb@panix.com>
2019-09-29 19:52 ` John W Higgins <wishdev@gmail.com>
2019-09-29 20:41 ` Rob Sargent <robjsargent@gmail.com>
2019-09-29 21:16 ` Adrian Klaver <adrian.klaver@aklaver.com>
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