mysql - currency exchange database schema -


i'm trying create database schema currency exchange. want have information various currencies every 30 seconds. schema had in mind.

column                      sql type fromcurrency (pk)           varchar tocurrency (pk)             varchar buyrate                     money sellrate                    money dateandtime                 timestamp 

all information in 1 table. on right track schema design? recommendations need changed?

designing currency-exchange modules needs more information due country , financial market targeting.
example in countries currency exchange under central bank supervisions, rate-types more extended, there conversion-rate (beside sell-rate , buy-rate) specific exchange-types. business rolls needed studied before design.
in design (in exaggerated sample), having 200 active currencies, user have 200 * 200 data entry per day!

btw
think need define tables:
currency_table: currency table currency definitions, details name,swift-code, ... precision(that shows how many precision acceptable , applied currency when calculation , rounding applied.
in currency-exchange context (at least have worked on), there fundamental concept called base-currency, it's currency of country application customized (some applications use usd embedded base currency).
base-currency currency defined in table specific attribute. base-currency root element rate comparisons , calculations.

rate_type_table: contains sell,buy, conversion , ... rate types (if having sell , buy, may ignore table , add 2 columns rate table, have done on question)

daily_rate-table: daily data entries exchange rates of currency

id (pk) currency_key(fk of currency table) rate_type_key(fk of rate_type table) amount (decimal) date 

any record in table, show currency value in comparison 1 block in base currency.
currency currency rate, need calculation source currency base currency , base currency target currency.
rounding critical mater in design , implementation of exchange modules.


Comments