Database Diagram Advice needed plus Normalization

Hi all,

I’m getting into the meat of my application, namely transitional
calculations between statistical tables. As a brief overview:

37 categorical statistics tables (independent data from one another) but
each belongs to an inheritance_template.rb model with
self.abstract_class = true so that methods can be shared and code is

Now my main ratings table will need to pull information from all 37
tables, and calculate variance between that data using standard
deviation and other advanced mathematics.

So, as an example of a motion diagram:

Ratings controller --> queries Table #1 of 37 pulling all records
–> standard deviation and offset for variance is calculated
–> new results are formed
----> (should these results be placed somewhere or stored in arrays?)
–> new results are further calculated and rating point modifiers are
----> rating point modifiers should be stored in a table
------> table should be accessible by ratings for further use

Ratings controller --> queries Table #2 of 37 pulling all records
etc. etc.

Now, at first glance the data being pulled is actually going to happen
one day each week so it’s probably better to “task” it using a rake
task. Or, do you disagree and if so, why? I could simply store the
method in the inheritance_template model and let the rake task call that
method and perform the calculations.

However, I need to have the results of those calculations saved
somewhere so that my ratings table can be created from those values.

So, I need some advice on how to proceed with this diagram and what you
would suggest about normalizing the data?

I’ve already created this entire platform in PHP but PHP is not rails.

Many thanks in advance.

I’m thinking along the lines of:

… calculations.rb

= which would run calculations for standard deviation and variation on
data provided to it…

… calculations.rake

desc “Calculate Ratings”
task :calculate_all_ratings => :environment do

calculate_rushing = RushingOffense.find(:all)

need to store the results somewhere…


= which would access each model and use a calculation method

RushingOffense model is part of inheritance_template.rb so the method
would be located in there…

class InheritanceTemplate < ActiveRecord::Base
self.abstract_class = true

def self.ratings
calculation_object =, statistic2, etc.)


= which would access the calculations.rb file which contains the method

Now I just need to figure out if this is a good approach, whether or not
I need to tie it into another controller as far as tasking goes, and how
to make it more automated…