Re: Another question about Range types - Mailing list pgsql-general

From David Johnston
Subject Re: Another question about Range types
Date
Msg-id 022201cd71c8$bd9c08d0$38d41a70$@yahoo.com
Whole thread Raw
In response to Re: Another question about Range types  (Mike Christensen <mike@kitchenpc.com>)
Responses Re: Another question about Range types  (Mike Christensen <mike@kitchenpc.com>)
List pgsql-general
>
> If I do switch to RANGE types, I think [2,2] would make sense in this
case.
> Using unbounded ranges might make sense if I wanted to express something
> like "Use up to 1 cup of flour" or "You'll need at least 3 cups of water".
>

In these cases:

Flour: [0, 1] - "optional, but maximum of 1-cup";  you cannot supply a
negative amount of ingredient...
Water: [3, ) - "at least three cups, but remember you will have to pay the
water bill at some point..."

The water example implies some need to flag the quantity as needing an
explanation.  In this case I would probably say "[3,3]" and set a flag so
that you can describe, in words, those situations where additional water
would be OK.  Mabye some kind of "quantity_precision" flag with possible
values of [EXACT,APPROXIMATE,MINIMUM,MAXIMUM].  The reason I say this is
because the value of storing an amount as a value is that it can be used in
calculations and it is difficult to use infinity in calculations.  By
storing a finite range you can more readily use the values in calculations
and when you care about whether the value is "required" or "suggested" you
have a flag you can query to tell you which it is.

David J.




pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: strategies for segregating client data when using PostgreSQL in a web app
Next
From: Mike Christensen
Date:
Subject: Re: Another question about Range types