Re: Best data type to use for sales tax percent

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org mailing list" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Best data type to use for sales tax percent
Date: 2009-10-09 19:18:17
Message-ID: 1255115897.28376.1.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2009-10-09 at 11:46 -0700, Christophe Pettus wrote:
> Domains are basically type aliases with an optional CHECK clause, so
> you could do something like:
>
> CREATE DOMAN sales_tax_rate AS DECIMAL(5,5) CHECK (VALUE >= 0);
>
> Then, you can use the type "sales_tax_rate" in your tables, etc. just
> as a normal first-class type. (The only limitation, right now, is
> that you can't create an array of them.)

Actually I wouldn't bother with the precision and scale at all. I'd go
with something like

CREATE DOMAN sales_tax_rate AS DECIMAL CHECK (VALUE >= 0 AND VALUE <=1);

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2009-10-09 19:36:04 Re: Best data type to use for sales tax percent
Previous Message Mike Christensen 2009-10-09 19:14:34 Re: Best data type to use for sales tax percent