Foreign Direct Investment (% GDP)
2000 2001 2002 2003 2004 2005 2006
Brazil 5.09 4.05 3.28 1.84 2.74 1.7 1.73
China 3.22 3.36 3.39 2.86 2.84 3.44 2.81
India 0.78 1.15 1.11 0.73 0.83 0.94 2.13
Mexico 2.87 4.43 3.37 2.35 3.11 2.57 2.01
I have 2 ideas for my Ruby on Rails application:
1) Have 3 models:
- MetricType will contain the type of metric (FDI) and will have many DataPoint objects
- DataPoint will have a value and year and will belong to one Country object and one MetricType object
- A Country object will also have many DataPoint objects (representing a row)
2) Less normalized but maybe more efficient for handling lots of data
- MetricType will contain the type of metric (FDI) and will have many DataSet objects
- DataSet will belong to one MetricType and one Country object
- DataSet will have an array of hashes to represent values - [{"year" => "value"},{"year" => "value"},...]
Are these both good methods for abstracting the data? Which would you use or would you propose an alternate method?
Thanks!