A really naive question. I have to store currency within the database. Both value and also the code. To resolve this, do people generally make 2 posts, one storing the worthiness along with other the code? Or perhaps is there an built-in type I'm able to use?


You will have to use two posts. I'd keep financial amount in a single column and also the alpha currency code in another column. In some instances, you'll have multiple amounts on one row. e.g. shipping amount and amount of taxes may both be around the invoice record. You will have to determine if these will share exactly the same currency or if you want two posts.

You need to use the ISO standard currency codes.

Some databases possess a Money type, which may be used to keep value. However, if you wish to store a code (would you mean dollars, euro's etc?) then you should make use of a second column.

Update: PostgreSQL does have a money type, even though it appears like it might only support one sort of currency therefore it still doesn't really suit your needs.

The relational databases I understand (Oracle, Postgres, MySQL) don't have built-in currency support, and that i pricier any others do. You'll have to do-it-yourself with 2 posts.

There might be tools specific for your db. Generally I'd think storing the currency like a real value along with a currency code indicator. There might be a standardized currency code list somewhere which you can use or simply make one up in line with the foreign currencies you realize you'll cope with.

Really if you wish to indicate a kind of all kinds you may need a column to keep the kind.

People might have the ability to provide more DB specific help should you indicate the DB you're using.