pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: stan <stanb@panix.com>
To: Michael Lewis <mlewis@entrata.com>
Cc: pgsql-general@postgresql.org
Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
Date: Fri, 20 Sep 2019 06:30:31 -0400
Message-ID: <20190920103031.GA21182@panix.com> (raw)
In-Reply-To: <CAHOFxGrZqPDOTheMT+kMb2sUSvg7SiFvr=d2-gugwxBr_mMDaw@mail.gmail.com>
References: <50d5b256-74b9-1949-a634-0df37cbfb783@aklaver.com>
	<20190916010439.GA7478@panix.com>
	<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>

On Thu, Sep 19, 2019 at 03:54:40PM -0600, Michael Lewis wrote:
> You can also look at citext type to avoid the casting.

Oh, that looks really useful I think I will go back and use that type quite
a bit.

Thanks for pointing it out to me.

> 
>     customer_key                integer DEFAULT
> nextval('customer_key_serial') PRIMARY KEY ,
>     cust_no                     smallint NOT NULL UNIQUE ,
>     name                        varchar UNIQUE ,
> 
> Why do you have a surrogate primary key generated by a sequence when you
> have a natural key of either cust_no or name? Why not just declare the
> customer number to be the PK? 

At the moment, the customer (who is a small startup) really does not have a
customer number. It is really a place holder at the moment, with the
sequence being the "real" key. For all I know, the customer number may be
alphanumeric. in the final implementation.

> Where does customer number come from anyway?
> Using smallint seems potentially short-sighted on potential future growth,
> but changing the type later should be minimal work as long as you don't
> have this customer_number denormalized many places, or use it as the FKey
> after dropping customer_key surrogate key.

Thanks for your suggestion.

-- 
"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: <20190920103031.GA21182@panix.com>
Permalink:  ../20190920103031.GA21182@panix.com/
Also on:    postgresql.org/message-id/20190920103031.GA21182@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, mlewis@entrata.com
  Subject: Re: FW: Re: FW: Re: Shouldn;t this trigger be called?
  In-Reply-To: <20190920103031.GA21182@panix.com>
  References: <50d5b256-74b9-1949-a634-0df37cbfb783@aklaver.com> <20190916010439.GA7478@panix.com> <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>

* 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