Skip to content

Instantly share code, notes, and snippets.

@neovintage
Created February 12, 2009 19:07
Show Gist options
  • Save neovintage/62820 to your computer and use it in GitHub Desktop.
Save neovintage/62820 to your computer and use it in GitHub Desktop.
Initial thoughts on a datamapper data warehouse gem
class DailySales
include DMDataWarehouse::Fact
dimension date
dimension product
dimension customer
property :quantity_sold, Integer
property :unit_amount, Float
property :sales_total, Float
end
class Date
# By specifying Dimension in your class, behavior should include:
# - Automatically include an id field.
# - Create has_many for all of the fact tables it belongs to
include DMDataWarehouse::Dimension
property :date, Date
property :day_of_week, String
property :month, Integer
property :year, Integer
end
class Customer
include DMDataWarehouse::Dimension
property :first_name, String
property :last_name, String
# by specifying outrigger, it will automatically generate belongs_to
outrigger first_purchase_date
end
class FirstPurchaseDate
# The outrigger is a way of specifying using database views.
# - We would specify the base table that we want to use
# - Maybe
# - We would not be able to write anything to the outrigger dimensions. READ-ONLY
# Only problem here is that we'd need to get database views supported at the
# adapter level. Not sure how messy that could get.
include DMDataWarehouse::Outrigger
base_table date
include_fields date, day_of_week, month, year
# This next one would be optional
prefix_field_names 'first_purchase'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment