Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyU3h-0006vH-SR for pgsql-general@arkaria.postgresql.org; Fri, 16 Aug 2019 04:41:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hyU3g-00042v-IP for pgsql-general@arkaria.postgresql.org; Fri, 16 Aug 2019 04:41:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyU3g-0003zz-6M for pgsql-general@lists.postgresql.org; Fri, 16 Aug 2019 04:41:48 +0000 Received: from gandalf.net-wizard.org ([138.201.143.9]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyU3d-0005FL-6G for pgsql-general@postgresql.org; Fri, 16 Aug 2019 04:41:46 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.net-wizard.org (Postfix) with ESMTP id 485E480FB2 for ; Fri, 16 Aug 2019 06:41:43 +0200 (CEST) X-Virus-Scanned: Gentoo amavisd-new at aragorn Received: from aragorn.net-wizard.org ([127.0.0.1]) by localhost (aragorn.net-wizard.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TzlH_S5Mdiba for ; Fri, 16 Aug 2019 06:41:43 +0200 (CEST) Received: from webmail.net-wizard.org (localhost [IPv6:::1]) by gandalf.net-wizard.org (Postfix) with ESMTP id 14F7C80E64 for ; Fri, 16 Aug 2019 06:41:43 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 16 Aug 2019 06:41:43 +0200 From: Charles Clavadetscher To: pgsql-general@postgresql.org Subject: Re: Variable constants ? In-Reply-To: References: <20190815205657.GA2593@panix.com> User-Agent: Roundcube Webmail/1.4-rc1 Message-ID: <11025034d9e2c2b5e0316aa1f80dfe68@swisspug.org> X-Sender: clavadetscher@swisspug.org Organization: Swiss PostgreSQL Users Group List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-08-15 23:27, Rich Shepard wrote: > On Thu, 15 Aug 2019, stan wrote: > >> I need to put a few bossiness constants, such as a labor rate >> multiplier >> in an application. I am adverse to hard coding these things. The best >> plan >> i have come up with so far is to store them in a table, which would >> have >> only 1 row, and a column for each needed constant. >> >> Anyone have a better way to do this? >> >> Failing a better way is there some way I can limit this table to only >> allow one row to exist? > > Stan, > > I've resolved similar issues with changing regulatory agency staff. For > your > application(s) I suggest a table like this: > > create table labor_rate_mult ( > rate real primary_key, > start_date date not null, > end_date date > ) > > This provides both a history of labor rate multipliers and the ability > to > select either the most current one or a previous one. > > If other factors affect the rate, add attribute columns for them. > > Regards, > > Rich Another way to keep a history is using a daterange instead of two columns for start and end date. Something like create table labor_rate_mult ( rate real primary_key, validity daterange not null ) This makes it easier to manage and avoid e.g. overlappings. Regards Charles