Talk to data warehouse style sheets with ActiveRecord?

As my Rails application matures, it becomes increasingly apparent that it has a strong data warehouse flavor, not having just a fact table to make everything explicit.

In addition, I just read chapters 2 (Designing beautiful APIs) and 3 (Mastering dynamic tools) of Ruby Best Practices .

Now I'm trying to figure out how best to create a fact-extracting part ...

Let's say I have the following sizes (existing models in the application):

  • Product (contains funds)
  • Fund
  • Measurement (e.g. general holding, medium holding, medium exposure)

... and the good old universal fact:

  • Fact (date, value plus NULLable column with foreign key for each of my dimensions)

Some aspects that I would be grateful for are some tips:

  • What could be a flexible search interface?
  • What happens if I have Facts with both NULL (i.e., all and without them) and NOT NULL (specific) values ​​for the dimension? Pseudo meaning like :all? Or should any convention apply?
  • How to select only a subset of dimension values? Or exclude a subset ?: only and: exclude?
  • Has anyone had experience creating named_scopeto handle this? There is the obvious attraction of being able to bind one for each aspect of interest, but does it make it too awkward if we get to 7 or 8 dimensions?

( , acts_as_fact, , - ( , RailsConf 2006 ), , .)

: Rails, ActiveRecord 2.1.2, Oracle Enhanced Adapter 1.2.0

EDIT: ActiveWarehouse :  - 2008 , 09 ;  - 2006 , , 404s ;  - , ActiveRecord - AR, , AR-.

, , !

+5
4

, , , , ( - , ).

, , , . , , , .

, , NULL . , , : .

Retrieval , named_scopes, , . , Hash, .

, ...

0

, NULL (.. ) NOT NULL () ? - : ? - ?

NULL , . , -1 ( foreign_key > 0).

? ?

with_scope()

   def self.find(*args)
    if  anything
      with_scope(a_scope) do
         result = super *args
      end
    else
      result = super *args
    end
   end

   def self.a_scope
    {:find => { :conditions => ["person_id  = ?", me] , :readonly => true}}
   end

- named_scopes ? , , 7 8 ?

olap 4- , . , active_record, .

: http://github.com/aeden/activewarehouse/tree/master

+2

I studied using ActiveWarehouse a while ago before I got it from other things, so I can’t tell you how well this works, but there is something to add to your list to check. It has generators for facts, sizes and cubes, as well as ETL tools.

+1
source

All Articles