Sunday, May 1, 2011

mondrian-olap

JRuby gem for performing multidimensional queries of relational database data using Mondrian OLAP Java library.

DESCRIPTION
SQL language is good for doing ad-hoc queries from relational databases but it becomes very complicated when doing more complex analytical queries to get summary results. Alternative approach is OLAP (On-Line Analytical Processing) databases and engines that provide easier multidimensional analysis of data at different summary levels.
One of the most popular open-source OLAP engines is Mondrian (mondrian.pentaho.com). Mondrian OLAP engine can be put in front of relational SQL database and it provides MDX multidimensional query language which is much more suited for analytical purposes.
mondrian-olap is JRuby gem which includes Mondrian OLAP engine and provides Ruby DSL for creating OLAP schemas on top of relational database schemas and provides MDX query language and query builder Ruby methods for making analytical queries.

USAGE
Schema definition
At first you need to define OLAP schema mapping to relational database schema tables and columns. OLAP schema consists of:
  • Cubes Multidimensional cube is a collection of measures that can be accessed by dimensions. In relational database cubes are stored in fact tables with measure columns and dimension foreign key columns.
  • Dimensions Dimension can be used in one cube (private) or in many cubes (shared). In relational database dimensions are stored in dimension tables.
  • Hierarchies and levels Dimension has at least one primary hierarchy and optional additional hierarchies and each hierarchy has one or more levels. In relational database all levels can be stored in the same dimension table as different columns or can be stored also in several tables.
  • Members Dimension hierarchy level values are called members.
  • Measures Measures are values which can be accessed at detailed level or aggregated (e.g. as sum or average) at higher dimension hierarchy levels. In relational database measures are stored as columns in cube table.
  • Calculated measures Calculated measures are not stored in database but calculated using specified formula from other measures.
Read more about about defining Mondrian OLAP schema at mondrian.pentaho.com/documentation/schema.php.

https://github.com/rsim/mondrian-olap

No comments: