David Fetter <david@fetter.org> writes:
> The "money" type is far too simplistic to model this kind of thing. A
> really sophisticated representation of money would have to take time,
> inflation/deflation, pairwise exchange rates, etc. into account. It
> would look more like a schema with a large data set and a large body
> of code loaded into it than it would a data type.
I don't think that's the appropriate functionality for a data type.
I used to be in the currency trading game (before I decided hacking
Postgres was more fun), and if you ask me, the people who want this
functionality are specifically interested in those exchange rates and
time variations --- it's exactly the purpose of their databases to
store, search, and manipulate that data, so burying it behind the scenes
in a datatype is exactly the wrong approach.
At least for what I was doing back then, a tagged type is exactly the
right thing: all we'd have wanted is for it to keep us from thinking
that adding 2 USD and 2 EUR directly was a sane computation.
Oh BTW: 10^14 is not enough dynamic range --- those guys push around
*serious* amounts of money. Bill Gates' net wealth is somewhere north
of 10^13 cents, and he's just a private citizen not a bank.
regards, tom lane