Answer the question
In order to leave comments, you need to log in
What is the best way to organize the storage of exchange rates?
What is the best way to organize the storage of exchange rates so that there are no problems?
All world currencies are required. At the first stage, one base is USD, later quotes of random pairs will be needed. Update - once a day.
The first is the data format. Esteemed, advise to use decimal (20,6). It is right?
Second - table organization
I see two options.
1. One table
id | timestamp | source | и туева хуча столбиков под каждую валюту
id | timestamp
relation_id | source | currency | value
Answer the question
In order to leave comments, you need to log in
if the Selections will "take a fresh (last, today's) USD to Tugrik quote" , why do you bother with the classic database at all?
received fresh quotes, put them in some kind of radish and use them. repeat every day.
if you need a story, then option 2.
6 decimal places may not be enough, in theory, I would take 8 just in case.
To organize tables, you first need to understand how these tables will be used.
If there is a selection of the type "select quotes for all currencies on the date", then the date should be a key (or index), then like this:
DATE / tueva hucha of
columns be a currency code.
CURRENCY CODE / Date / Rate
TimeStamp is needed only if your value changes within one day. Usually the rates are set per day, so one date is enough.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question