A very naive question. I need to store currency in the database. Both the value and the code. To solve this, do people generally make 2 columns, one storing the value and other the code? Or is there an inbuilt type I can use?
-thanks
A very naive question. I need to store currency in the database. Both the value and the code. To solve this, do people generally make 2 columns, one storing the value and other the code? Or is there an inbuilt type I can use?
-thanks
You will need to use two columns. I would store the monetary amount in one column and the alpha currency code in another column. In some cases, you will have multiple amounts on a single row. e.g. shipping amount and tax amount may both be on the invoice record. You will need to decide if these will share the same currency or if you need two columns.
You should use the ISO standard currency codes.
Some databases have a Money type, which can be used to store the value. However, if you want to store a code (do you mean dollars, euro s etc?) then you would need to use a second column.
Update: PostgreSQL does have a money type, although it looks like it would only support one type of currency so it still does not really meet your needs.
The relational databases I know (Oracle, Postgres, MySQL) do not have built-in currency support, and I don t expect any others do. You will have to do it yourself with 2 columns.
There may be tools specific to your db. In general I would think storing the currency as a real value and a currency code indicator. There may be a standardized currency code list somewhere that you can use or you can just make one up based on the currencies you know you will deal with.
Really if you want to indicate a type of any sort you will need a column to store the type.
People might be able to provide more DB specific help if you indicate the DB you are using.
$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...
I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...
I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...
Does anybody know if it is possible to move some (not all) users from one ASP.NET membership database to another? (for the purposes of migrating some users to another database on another machine, but ...
Is it because of size? By the way, what is the limit of the size?
I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...
For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...
I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...