pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: stan <stanb@panix.com>
To: Morris de Oryx <morrisdeoryx@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
Date: Fri, 20 Sep 2019 07:08:46 -0400
Message-ID: <20190920110846.GB12885@panix.com> (raw)
In-Reply-To: <CAKqnccjQUE5V-P+4BCg34UFoxq0=KNQLdQD+6qcr3ocn_wre=g@mail.gmail.com>
References: <11b4428d-8740-07f4-a053-37f0bb0cd2fb@aklaver.com>
	<20190916185333.GB28966@panix.com>
	<b1b8bfde-a836-c05f-fa2f-01ee29d93032@aklaver.com>
	<20190916195543.GA16882@panix.com>
	<4b1da094-8342-6415-e0a4-ce87fd1331ab@aklaver.com>
	<20190917093126.GA935@panix.com>
	<699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com>
	<CAHOFxGrZqPDOTheMT+kMb2sUSvg7SiFvr=d2-gugwxBr_mMDaw@mail.gmail.com>
	<20190920103031.GA21182@panix.com>
	<CAKqnccjQUE5V-P+4BCg34UFoxq0=KNQLdQD+6qcr3ocn_wre=g@mail.gmail.com>


On Fri, Sep 20, 2019 at 08:52:00PM +1000, Morris de Oryx wrote:
> I see that you've already been pointed at citext, but I don't think a CHECK
> constraint has been mentioned. In case it hasn't, what about something like
> this?
> 
>    ADD CONSTRAINT check_activity_status
>     CHECK (activity_status = 'ACTIVE' OR activity_status = 'INACTIVE');
> 
> I'm kind of allergic to ENUM...maybe that's just me. But since you're
> considering it, maybe it's the perfect time to consider all of your
> options. Such as a linked lookup table of defined allowed values (feels
> silly with two values), a domain (not entirely fit to purpose), or the
> CHECK constraint above. And, yeah, if it's only ever ACTIVE or INACTIVE,
> I'd normally make a Boolean named something like active, as Adrian Klaver
> mentioned. That's easy to reason about, and it makes it unambiguous that
> there are two and only two possible states..

Thanks you.

I actually have a number of these cases, and I sullied the simplest one,
which just has 2 values. I guess my "C: background is showing here.

I do have some similar situations where I did use a table of allowed
conditions. I am thinking citext may be the best solution here.

I am having an issue getting it to work, though. I don't have to do
anything special to enable this type, do I?

What I am really trying to do is "human proof" this input :-)

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin





view thread (24+ messages)  latest in thread

Message-ID: <20190920110846.GB12885@panix.com>
Permalink:  ../20190920110846.GB12885@panix.com/
Also on:    postgresql.org/message-id/20190920110846.GB12885@panix.com

 · 

reply

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: stanb@panix.com, morrisdeoryx@gmail.com
  Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
  In-Reply-To: <20190920110846.GB12885@panix.com>
  References: <11b4428d-8740-07f4-a053-37f0bb0cd2fb@aklaver.com> <20190916185333.GB28966@panix.com> <b1b8bfde-a836-c05f-fa2f-01ee29d93032@aklaver.com> <20190916195543.GA16882@panix.com> <4b1da094-8342-6415-e0a4-ce87fd1331ab@aklaver.com> <20190917093126.GA935@panix.com> <699cb705-0609-c830-b6c3-3a4aa9bc2e58@aklaver.com> <CAHOFxGrZqPDOTheMT+kMb2sUSvg7SiFvr=d2-gugwxBr_mMDaw@mail.gmail.com> <20190920103031.GA21182@panix.com> <CAKqnccjQUE5V-P+4BCg34UFoxq0=KNQLdQD+6qcr3ocn_wre=g@mail.gmail.com> <20190920110846.GB12885@panix.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