the ultimate-generic date/time framework - in depth

Post on 17-Jun-2015

384 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

An in depth explanation of the ultimate generic date/time framework Also view: http://ginoscheppers.wordpress.com/2010/12/19/ultimategenericdatetimeframework/

TRANSCRIPT

13/04/23 1

Best Practices - Universe Design

How to implement the ultimate DateTime Dimension Class? Gino Scheppers(gino.scheppers@telenet.be) 16/12/2010

IntroductionSupercharge Your Universe with Time-

Series AnalysisAfter an idea of David Taylor

-But optimized for DateTime-fields with a

ultimate generic flavor.-

Important: First read David Taylor’s Blog, do get familiar with the idea

Recipe for Simplicity

Today, Yesterday, Last Year, Last Quarter, Last Month,… are common date ranges that I like to use over and over, unfortunately BusinessObjects doesn’t provide this out of the box… but with a little creativity, you can build it yourself. It’s quite simple really and when you see how simple it is, you will be shocked.

IntroductionImagine dropping a datetime-filterobject into the Query Filters-panel, and when the end-user runs the query he automatically receives a ‘Predefined Date Range’ –prompt. Wouldn't that be great?

Introduction Or the user himself can create from a set of predefined Prompts or Objects his own range. Wouldn’t that be great?

Benefits of this approach?

Extreme easy to understand and use from a end-user point of view.

The created Date/Time prompts and objects are ‘platform independent’ !

Especially useful for ad-hoc universes. Filtering on Database-query-level instead of

report level will reduce the number of retrieved records

Extremely boost universe developing time (each designer can easily reuse the template-universe)

A consistent look and feel for all universes, and for all users

How to setup (in a nutshell)?(tip: study the Oracle-template universe)

1. Create a derived table with calculated dates and three columns (Name of the Range, Start Date, End Date)

2. Create one simply class with four objects + filter object.

3. For every date/time object in your universe, create one corresponding filter/prompt - object

Tip 1: Step 1 & 2 can be implemented in a template universe for reuse.

Universe overview

12

3

1. Create a derived table

2. Create 4 objects

3. For each datetime field create a customized filter object

Step 1 The first thing we need to create is a

database view with calculated dates which will change automatically from one day to the next. The table will contain three columns: Name of the Range Start Date End Date

With these three columns we can build any date-selection we wish. Here are what the results look like when you view the table:

Derived date-range table Derived table implementation. (Check

the template universe for the query)

Step 1 (next)

Here comes the tricky part, David suggest to create a BETWEEN-join between the date field on your fact table and the start and end dates within the Date Range Table.

That’s, maybe a good idea (if you have only a few date

fields), but this will create a confused universe-view when you have lots of date fields. Imagine all those BETWEEN-joins, between the derived table and your date-fields. And what about the created loops?

Step 1 In fact, with the following setup

you don’t need any join between the derived table and your date fields.

So, ending up with a nice and easy to maintain universe.

Just follow the next steps, to get the clue.

Step 2 Create a Date/Time class with 4 objects. One

object will do the ultimate trick. Lets start with this genius object.

1. Create the object, lets call it ‘GenericDateDimension’2. Drop the ‘derived table query’ into the select box.

(don’t parse it, parse will fail, because this is an undocumented feature!) (see next slide)

3. Hide the object! We will reuse this object with the @select

function in every datetimestamp – filter-object! If the derived table query is updated, only one

object, the ‘GenericDateDimension’ needs an update, and all filter/prompt objects will change too. (=maintenance reduction!)

Step 2 (next)

Lets look at a Oracle 10g example

Step 2 (next)

Create three more object for the following fields in the derived table.

Date range With customized LOV (fields: date_range,

begin_date,end_date) Customized the where clause Disable sort and condition

Begin Date Format the object (dd/mm/yyyy hh:MM:ss) Disable sort and condition

End Date Format object (dd/mm/yyyy hh:MM:ss) Disable sort and condition

Why do you need those objects? Use them in every report in an separate query (to prevent an cartesian product)! And use them to inform your report-reader about the selected date-range.

Step 3 For every date/time object create a

corresponding filter with prompt and assist your business user to use the filter! Of course, provide some documentation in the description zone of the object.

And now the tricky part, how to setup the ultimate - where-clause, in the filter-object?

Step 3 (next)

Using two subqueries in combination with a between condition and two identical prompts will do the ultimate trick and will eliminate ‘lots of joins’ in the universe!

Fact-date-field between (Select begin_date from @select(derived table) where daterange=@prompt(“Enter reporting date range”,…)

and(Select end_date from @select(derived table)

where daterange=@prompt(“Enter reporting date range”,…)

Example of Filter-on a datetime –field.

Change this for every created filter object

And the final touch

A little bit lazy, and you don’t want to create filter objects? No panic.

1. Cut and paste the predefined Miscellaneous Date/Time Objects from the template universe.

2. Learn the user how to use a between condition and the predefined Range objects, and the sky is the limit!

The ultimate generic date table! (bonus )

Oeps, the database administrator has forgotten to implement a date dimension table!

No panic, with the following generic solution you can build a date dimension table on the fly.

To good to be true? Read the following slides to discover the trick.

Basic setup You need one derived table, lets call it

‘GenericDateTable’ A combination of sub-select queries and

some cartesian-products will do the trick. Before you go any further, study the query

‘GenericDateTable’ in the template universe.

With the ones, tens and hundreds-table, and forcing a cartesian product; a running number field is created and subtracted from the calc_date (=current date) field in the table (that’s all!) (You need SQL skills to understand the query )

Do you need Holidays ? Create an other derived table, with all the necessary holidays Create an outer-join with the ‘GenericDateTable’ Create some additional holiday objects in the Generic Date Table

class. (Workday-Holiday is a cool one)

Let’s start using the universe(read the slides Quick Start & Setup,to get up and running)

Donations are welcome on PayPal account gino.scheppers@telenet.be

top related