How to keep the prices of goods in the database?

Hello, there are online store. For example, two currencies - the dollar and the Euro. One of the currency is current, that is, one in which all prices on the website. For example, in a database recorded all the prices in dollars and you need to change the current currency to the Euro. It is unlikely prices in the database will have to be recalculated every time when you change the current currency? As usual kept the price of goods? Assume that prices in the default currency, a currency for another price displayed in the output view converted to another currency to the current rate?

Thank you.
March 23rd 20 at 19:03
3 answers
March 23rd 20 at 19:05
Good to avoid unnecessary errors to keep one base price.
And the table with the current exchange rate.
And when prompted to convert.

Otherwise, let's say you have 5 currencies. And a lot of goods.
You change the price tag at the time of the price change something and children not so dead, are not associated database where each other chaotically mismatched.
and when a product is always to make the price of the underlying currency? - helmer77 commented on March 23rd 20 at 19:08
It all depends on whether you need history.
If the story needs it the price is better not to bind to the item card and to assign a document type to set prices.
Then the implementation will be more difficult but you can always check what was the cost on a certain date.
If the story changes are not needed and it is possible when creating a product to assign. - haleigh_Koch commented on March 23rd 20 at 19:11
March 23rd 20 at 19:07
keep a separate table with the current course, and in the product currency which made its cost. The rest - rendering
March 23rd 20 at 19:09
Yes, you can store default currency, and display to the user depending on the selected currency (on the way to calculate it at the current rate)

And can be stored in the database of prices in several currencies.
In my opinion, roughly the same options from the point of view of correctness)
and every time you change course to rewrite all the records?)) - izaiah.Wucke commented on March 23rd 20 at 19:12
@izaiah.Wucke, but can do discounts only for a specific currency :))

A table with the current rate, by far the best option I had not thought about it - adolf_Leannon93 commented on March 23rd 20 at 19:15

Find more questions by tags Web DevelopmentDatabases