the ultimate-generic date/time framework - in depth

23
14/06/22 1 Best Practices - Universe Design How to implement the ultimate DateTime Dimension Class? Gino Scheppers ([email protected] ) 16/12/2010

Upload: gino-scheppers

Post on 17-Jun-2015

384 views

Category:

Technology


1 download

DESCRIPTION

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

TRANSCRIPT

Page 1: The Ultimate-Generic Date/Time Framework - In depth

13/04/23 1

Best Practices - Universe Design

How to implement the ultimate DateTime Dimension Class? Gino Scheppers([email protected]) 16/12/2010

Page 2: The Ultimate-Generic Date/Time Framework - In depth

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

Page 3: The Ultimate-Generic Date/Time Framework - In depth

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.

Page 4: The Ultimate-Generic Date/Time Framework - In depth

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?

Page 5: The Ultimate-Generic Date/Time Framework - In depth

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

Page 6: The Ultimate-Generic Date/Time Framework - In depth

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

Page 7: The Ultimate-Generic Date/Time Framework - In depth

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.

Page 8: The Ultimate-Generic Date/Time Framework - In depth

Universe overview

12

3

1. Create a derived table

2. Create 4 objects

3. For each datetime field create a customized filter object

Page 9: The Ultimate-Generic Date/Time Framework - In depth

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:

Page 10: The Ultimate-Generic Date/Time Framework - In depth

Derived date-range table Derived table implementation. (Check

the template universe for the query)

Page 11: The Ultimate-Generic Date/Time Framework - In depth

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?

Page 12: The Ultimate-Generic Date/Time Framework - In depth

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.

Page 13: The Ultimate-Generic Date/Time Framework - In depth

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!)

Page 14: The Ultimate-Generic Date/Time Framework - In depth

Step 2 (next)

Lets look at a Oracle 10g example

Page 15: The Ultimate-Generic Date/Time Framework - In depth

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.

Page 16: The Ultimate-Generic Date/Time Framework - In depth

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?

Page 17: The Ultimate-Generic Date/Time Framework - In depth

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”,…)

Page 18: The Ultimate-Generic Date/Time Framework - In depth

Example of Filter-on a datetime –field.

Change this for every created filter object

Page 19: The Ultimate-Generic Date/Time Framework - In depth

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!

Page 20: The Ultimate-Generic Date/Time Framework - In depth

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.

Page 21: The Ultimate-Generic Date/Time Framework - In depth

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 )

Page 22: The Ultimate-Generic Date/Time Framework - In depth

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)

Page 23: The Ultimate-Generic Date/Time Framework - In depth

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

Donations are welcome on PayPal account [email protected]