I'm making a Rails app which will feature a lot of "calculated" or "aggregated" data, i.e. information which is computed by performing expensive operations on the data stored by the user. I'm thinking I need some way of storing this data so A. I am not constantly performing expensive DB operations, and B. So that I can spit out "reports" with pretty graphs over time etc for given attributes.
I'm wondering what the best way to implement this is? I'd need to be calculating and storing values (numeric) for a given model, and how they change over time. I want this to be efficient and avoid duplicating and data. The records will be pretty much fixed once created, so I don't need to worry about things being changed too much, though it needs to be considered.
I just wondered what the most common approach to this is, and how I should go about implementing this within a Rails app?
I've been working on a similar problem and I've also worked on applications that did this the wrong way.
Here is my best-practices recommendation:
Feed
FeedStats
. This may also be a one-to-many association or many-to-one, depending on the exact case; you might roll up some individual Feed
records into some sort of aggregate, etc.If you can be a bit more specific and give some examples of your exact problem, I can perhaps give some more specific tips. Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With