Hi,

I am new to this datawarehouse concept. I am trying to create a dw. I have
one dimension and one fact, namely: waste_dimension.rb, waste_fact.rb

Location of elt is db/elt

*My database.yml is something like:*

etl_execution:
  adapter: mysql
  database: rails_warehouse_etl_execution
  username: root
  password: password
  host: localhost

warehouse:
  adapter: mysql
  database: for_demo
  username: root
  password: password
  host: localhost

 *I am using database for extract and load.*

 *I am able to create a simple dimension table using following code:*

source :in, {
    :database => "for_demo",
    :target => :warehouse,
    :table => "wastes",
    :select => "wastes.name, wastes.type_id",
    :order => "wastes.name"
},
[
    :name,
    :type_id
]

transform :name, :default, :default_value => "No Name"


destination :out, {
    :database => "rails_warehouse_etl_execution",
    :target => :etl_execution,
    :table => 'waste_dimension'
},
{
    :order => [
        :name,
        :type_id
    ]
}

Now I need to populate the watse_facts table. I am not sure how to go about
it. How do I add waste_id which is a foreign key from waste_dimesions table.
Also I wanted to add additional information from wastes table to waste_facts
table like co2e_factor (which I have not included in waste_dimensions table)

Structure for waste_dimension and waste_facts table is as follows:

class CreateWasteDimension < ActiveRecord::Migration
  def self.up
    fields = {
      :name => :string,
      :type_id => :integer
    }
    create_table :waste_dimension do |t|
      fields.each do |name,type|
        t.column name, type
      end
    end
    fields.each do |name,type|
      add_index :waste_dimension, name unless type == :text
    end
  end

  def self.down
    drop_table :waste_dimension
  end
end


class CreateWasteFacts < ActiveRecord::Migration
  def self.up
    # you should add indexes for each foreign key, but don't add
    # the foreign key itself unless you really know what you are doing.
    create_table :waste_facts do |t|
      t.column :waste_id, :integer, :null => false
      t.column :co2e_factor, :integer, :default => 1
    end
    add_index :waste_facts, :waste_id
  end

  def self.down
    drop_table :waste_facts
  end
end

As I could not get any information on net hence mailing on this list. Please
help me resolve this problem. Thanks!
_______________________________________________
Activewarehouse-discuss mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/activewarehouse-discuss

Reply via email to