I am using Postgres 9.3.

I have to store range data like <$250K, $250K-$4M, etc which we will display in a dropdown.

now I am making a table for all possible options that can be configured from an admin interface.

Should I take separate column for min,max,currency_type(dollar,euro) and a column to store K,M etc or there is a better way to do that ?

  • 1
    Three columns: Start, End, CurrencyType. E.g. 0, 250, USD – CodeART Feb 6 '14 at 12:12
  • 1
    just a suggestion: do not store K or M (order of magnitude) in the database. This is considered display/formatting logic and can be calculated on the fly. I'd even go as far as saying it should be calculated on the fly because it is a more flexible approach. – MetaFight Feb 6 '14 at 12:51
  • @MetaFight: More importantly, you can't compare 5K to 4M. But you can compare 5000 and 4000000. So you can't do things like finding the overlaps in ranges. Of course, if you're not going to do all of that, you might as easily store the range as a display string. – pdr Feb 6 '14 at 12:54
  • I am using postgres datatype range. that should be fine right ? – Amogh Talpallikar Feb 6 '14 at 14:35
  • What relevance does the range data type have here? – Robert Harvey Feb 6 '14 at 17:05

Guessing you will be needing ranges for different kinds of dropdowns;

enter image description here


If these are intended to be all-encompassing ranges that all values must fall within, I'd just store either the maximum or minimum value of the range in a single column.

ID | Amount 
 1 |      0
 2 | 250000 
 3 | 500000 
 4 |1000000 
 5 |2000000

You can calculate the actual ranges on the fly from this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.