Every repository with this icon (
Every repository with this icon (
Documentation
Introduction
The ActiveWarehouse plugin provides the basis for constructing a data warehouse reporting application with Ruby on Rails. ActiveWarehouse defines base classes that model common patterns in data warehousing such as facts, dimensions, cubes, aggregates and more.
Installing
ActiveWarehouse is a plugin for Ruby on Rails. You will need to install Ruby, RubyGems and Ruby on Rails first. Once Rails is installed you will need to create a Rails application. Once the Rails application has been created, cd into the new Rails application’s base directory and type:
script/plugin install git://github.com/aeden/activewarehouse.git
Facts
Facts represent the measures of a business. For example, a fact table might have one row for each point-of-sale transaction that has occurred. The fact table would hold both foreign key references to the dimensions that are relevant for that fact as well as a set of measurements for the fact. The measurements might include things like sale amount, quantity, etc.
To construct a fact in ActiveWarehouse:
script/generate fact name
This will create several code files, including:
- A class called NameFact that extends from ActiveWarehouse::Fact
- A migration called something like 001_create_name_fact
- A test stub for the fact
Dimensions
Dimensions represent the elements and entities in a business. Examples of dimensions include date, products, employees, users, stores, etc. Dimensions include a surrogate primary key along with as many attributes about the dimension as possible.
To construct a dimension in ActiveWarehouse:
script/generate dimension name
This will create several code files, including:
- A class called NameDimension that extends from ActiveWarehouse::Dimension
- A migration called something like 001_create_name_dimension
- A test stub for the dimension
Date Dimensions
script/generate date_dimension
Slowly Changing Dimensions
There are several types of slowly changing dimensions. Type 1 slowly changing dimensions are implemented by replacing an existing attribute in a row in the dimension table. Type 2 slowly changing dimensions include an effective date and an expiration date on each row in the dimension. When a change occurs for a dimension the old row is updated, setting the expiration date and a new row is inserted with the current date as the effective date and an expiration date at the maximum value in the future allowed.
class EmployeeDimension < ActiveWarehouse::Dimension
acts_as_slowly_changing_dimension
end
Ragged Hierarchies
Ragged hierarchies are hierarchies where each branch can be to any depth, and the depth between branches may vary. These types of hierarchies are used to model things like corporate structures.
In ActiveWarehouse you can use the HierarchalDimension mixin to add hierarchical dimension behavior to any of your dimension classes.
class EmployeeDimension < ActiveWarehouse::Dimension
acts_as_hierarchical_dimension
end
Role-Playing Dimensions
Role-playing dimensions are essentially views on top of an existing dimension that provides an prefixed name for each field in the dimension. The idea behind this is to allow facts to reference the same dimension by different names without needing utilize additional storage space. The most common use pattern is with dates. Consider a date fact
Bridges
Cubes
To create a cube in ActiveWarehouse:
script/generate cube transaction
Aggregates
Aggregates are the workhorses of ActiveWarehouse. Aggregates provide the logic for aggregating values in fact tables across one or more dimensions.
NoAggregate
The default aggregate implementation in ActiveWarehouse is the NoAggregate. This aggregate maps from a cube query to a SQL query.
Reports
Report classes contain information on how to build a report from a cube. Currently only the TableReport class is implemented.
AbstractReport
The AbstractReport abstract base class provides the following attributes:
- :pass_params
- :column_filters
- :row_filters
- :conditions
- Optional conditions String.
- :cube_name
- Specify the cube name.
TableReport
The TableReport class extends from the AbstractReport and adds additional parameters used for tabular reports.
- :format
- :link_cell
- :html_params
View Helpers
ActiveWarehouse currently comes with only a single view helper called report_helper. This helper is used to create an HTML report given a Report instance. The report_helper method has one required argument and one optional argument:
report_helper(report, html_options={})
The report is an instance of a Report class. Currently only the TableReport is implemented. The HTML options is a Hash of options used during the rendering of the HTML table. It currently accepts the following name/value pairs:
- :report_class
- The CSS class name used for styling the report. The default value is ‘report’.
License
Copyright (c) 2006-2009 Anthony Eden Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.






