Re: FW: Re: FW: Re: Shouldn;t this trigger be called?

From: stan <stanb(at)panix(dot)com>
To: Morris de Oryx <morrisdeoryx(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
Date: 2019-09-20 11:08:46
Message-ID: 20190920110846.GB12885@panix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Gallagher 2019-09-20 11:50:32 Web users as database users?
Previous Message stan 2019-09-20 11:02:58 Re: FW: Re: FW: Re: Shouldn;t this trigger be called?