Aggregating Data in Rails 3 -
i want aggregate data different sources, twitter lastfm , sort. can't figure out how store data. in database can't figure out how abstract make table hold data without compromising logical understanding of data in each column. wondering if else had experience , tackled in rails.
one option, if want stick sql, have model/table contains fields common every data source (title, url, summary) associated other models/tables contain fields specific individual data sources. associations regular or polymorphic. , if wanted in metaprogramming use method_missing delegate method calls fields not present in 'common' model associated models. work best polymorphic join. psudeo-code:
class datasource belongs_to :data_source_extension, :polymorphic => true def method_missing(method) if data_source_extension.responds_to? method data_source_extension.send(method) else super end end end
the other option sti, 1 table fields , 'type' field tells rails model record should wrapped in. depends on how many different sources have , how different each other.
if fields don't need searchable storing hash in text field works well. see serialize , attr_bucket gem.
or if want trendy nosql type database allows on-the-fly fields generated.
Comments
Post a Comment