[Dbix-class] DBIx::Class Component for Snowflake Schemas

Matt Follett matt.follett at gmail.com
Tue Mar 31 16:55:35 BST 2009


Hello all,

I've been working with generating reports from Star/Snowflake schemas.  As
such I've written a module that makes this a little easier, at least for
me.  The module consists of a Dimension and a Fact component.

Loading the Dimension component in a class provides two pieces of
functionality, it allows you to assign columns of that table that should be
ignored and it allows you to get a listing of all of the columns that are
related to that dimension across any of the tables that are related to it.
In a Star schema this will just return the columns you aren't ignoring and
in a Snowflake schema this'll recursively walk through the tables to gather
all of the columns.  The data for that is returned as an array of hashes
containing the column name and the column data type.

The Fact component provides those two subroutines and a third called
generate_report.  This subroutine takes a hash ref like so:
{'filters' =3D> {'dimedate.day_of_week' =3D> 3}, 'metric' =3D>
{'dimline.line_velocity' =3D> 1}}
And would return the ResultSet after converting the line_velocity value to
an appropriate value for that fact table and  would now include a column
'dimdate.day_of_week' with the values from whatever related dimension table
that came from.

The module allows you to to make a full round trip.  So, you could ask a
fact table what attributes are available, provide those to another source,
get back the attributes requested for filtering and viewing, and then pass
those back to the fact through generate_report.

You can download the module from here:
http://tinyurl.com/c7gr3t

Does anyone have some comments or recommendations on it?  I still need to
fix up some of the documentation, it's there but it's not complete.  Once
that is done do you think this would be worth putting on CPAN as
DBIx::Class::Snowflake?

Thanks for your time,
Matt Follett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090331/0ed=
5893b/attachment.htm


More information about the DBIx-Class mailing list