Hey,
sorry if the question is in the wrong place, but I need some help to get started.
I'm currently learning on data warehousing for university and my work and want to build a small data warehouse for a project myself. Now I found this gem and trying to understand this gem's usage.
I made myself familiar with star schema, snowflake schema etc. but I don't really understand how I link the FactTable with the actual table in the database.
I know it should be a table with some belongs_to associations to the dimensions, but how would I specify a migration for this? At least I didn't find an example in the docs.
So consider my following example where I'm modeling a simple cube for reporting details to hospital stays and patients. I have 3 model - patient, case and diagnoses:
create_table "cases", force: :cascade do |t|
t.string "casenumber"
t.date "admission_date"
t.date "discharge_date"
t.bigint "patient_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["patient_id"], name: "index_cases_on_patient_id"
end
create_table "diagnoses", force: :cascade do |t|
t.string "icd_code"
t.text "icd_description"
t.bigint "case_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["case_id"], name: "index_diagnoses_on_case_id"
end
create_table "patients", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.date "birthdate"
t.string "gender", limit: 1
t.string "domicile"
t.string "street"
t.integer "zip_code"
t.integer "house_number"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
add_foreign_key "diagnoses", "cases"
Now I have a CaseFactModel with the dimensions patient, case and diagnoses
class CaseFactModel < ActiveReporting::FactModel
self.model = CaseFact
dimension :patient
dimension :case
dimension :diagnosis
# dimension_filter :for_admission_date, ->(year) { joins(:case).where('extract(YEAR from admission_date) = ?', year) }
end
class CaseFact < ApplicationRecord
belongs_to :case
belongs_to :patient
belongs_to :diagnosis
end
Now, from what I've read this FactTable has to be a database table aswell, right? In the example test files in the repository I couldn't find any migration related to the fact tables.
And how does this FactModel map to this table then, as it's not inheriting from ActiveRecord::Base?
Am I getting something completely wrong here? Any help is appreciated, thanks in advance!
Hey,
sorry if the question is in the wrong place, but I need some help to get started.
I'm currently learning on data warehousing for university and my work and want to build a small data warehouse for a project myself. Now I found this gem and trying to understand this gem's usage.
I made myself familiar with star schema, snowflake schema etc. but I don't really understand how I link the FactTable with the actual table in the database.
I know it should be a table with some belongs_to associations to the dimensions, but how would I specify a migration for this? At least I didn't find an example in the docs.
So consider my following example where I'm modeling a simple cube for reporting details to hospital stays and patients. I have 3 model - patient, case and diagnoses:
Now I have a
CaseFactModelwith the dimensionspatient, case and diagnosesNow, from what I've read this FactTable has to be a database table aswell, right? In the example test files in the repository I couldn't find any migration related to the fact tables.
And how does this FactModel map to this table then, as it's not inheriting from ActiveRecord::Base?
Am I getting something completely wrong here? Any help is appreciated, thanks in advance!