If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > how to best design a "foreign currency" attribute???

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-26-04, 04:20
cybershadow_jp cybershadow_jp is offline
Registered User
 
Join Date: Dec 2003
Location: Tokyo Japan
Posts: 26
Question how to best design a "foreign currency" attribute???

how would one best design a foreign currency value (DBMS-independent)?

the idea that i have in mind would be the following:

--------------

TM_CURRENCY_MASTER table
CurrencyID : integer
CurrencyName : varchar
CurrencyCountry (??) : varchar

T_CURRENCY_MATRIX table
CurrencyID_1 : integer
CurrencyID_2 : integer
ExchangeRate : decimal

--------------

the actual transaction table would then have the following fields (considered as a SET):

...
etc
...
CurrencyID : integer
CurrencyAmount : decimal
...
etc
...


what do you people think?

thanks!!!
Reply With Quote
  #2 (permalink)  
Old 03-26-04, 06:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,516
sounds good

i like the second table, with

CurrencyID_1 : integer
CurrencyID_2 : integer
ExchangeRate : decimal

this allows an exchange rate for CurrencyID_1 --> CurrencyID_2 that is different from the inverse rate for CurrencyID_2 --> CurrencyID_1

you're probably want a time stamp somewhere, because rates do change frequently
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-26-04, 10:04
Pat Phelan Pat Phelan is online now
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,598
Yes, currency exchange rates change frequently. Worse yet, you can have more than one exchange rate in effect at the same time (for example, the rate from US Dollars to Euros may be different in Cairo and Tokyo at any given point in time! Because of that, for each exchange rate row you want both a begin and an end date (to allow multiple rates to be active at one time).

-PatP
Reply With Quote
  #4 (permalink)  
Old 03-28-04, 19:24
cybershadow_jp cybershadow_jp is offline
Registered User
 
Join Date: Dec 2003
Location: Tokyo Japan
Posts: 26
thanks for the suggestion regarding a "start" date, and a "end" date... and of course, the "timestamp"...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On