Tuesday, May 1, 2018

A pragmatic approach for reference data management: Cognos BI Modelling and implementation issues

 
Context
- Netezza as databases
- Cognos as report tool
 
Goal
- Make development easier – All ETLs will use the centralized table to get dimension business key, also all these map will be used to validate dimension tables as needed
- Make maintenance easier – when some changes applies duo to business logic change, we don’t need to change ETL and Cognos model
 
Assumptions
- Focused area is from staging data to data mart data
- SCD concept with surrogate key is NOT applied

Detail assumption of staging table
- All these dimension related columns are not NULL.
- If the column is NULL, then setup as ‘-99’ for string, or as -99 for number.
- If the column cannot be found from reference table, then setup as ‘-1’ for string, or as -1 for number.
 
Capabilities
- Handle single value mapping
- Handle data range mapping
- Handle default
- Generate exception between map and dimensions
 
Mapping table
-- DDL
DROP TABLE MPL_BI.REFERENCE_DATA_MAP IF EXISTS;
CREATE TABLE MPL_BI.REFERENCE_DATA_MAP 
(
 SOURCE CHARACTER VARYING(100) NOT NULL,
 PARAMETER_NAME CHARACTER VARYING(100) NOT NULL,
 SINGLE_VALUE CHARACTER VARYING(100),
 LOW_BOUND_VALUE DECIMAL(20,2), 
 LOW_BOUND_INCL_VALUE DECIMAL(20,2),
 HIGH_BOUND_VALUE DECIMAL(20,2),
 HIGH_BOUND_INCL_VALUE DECIMAL(20,2),
 DIMENSION_NAME CHARACTER VARYING(100) NOT NULL,
 DIMENSION_ITEM_NAME CHARACTER VARYING(100) NOT NULL,
 NOTE CHARACTER VARYING(1000),
 LAST_UPDATE_USER CHARACTER VARYING(100) ,
 LAST_MOFIFIED_DATE  DATE ,
 START_DATE DATE NOT NULL,
 END_DATE DATE
);
Sample Data
INSERT INTO MPL_BI.REFERENCE_DATA_MAP values('ALL','MAP_SINGLE_VALUE','Current (0)',NULL,NULL,NULL,NULL,'DIM_SINGLE_VALUE','NOT DELINQUENT',NULL,NULL,NULL,'2018-03-01',NULL);
.............
select * from MPL_BI.REFERENCE_DATA_MAP;
 
SOURCEPARAMETER_NAMESINGLE_VALUELOW_BOUND_VALUELOW_BOUND_INCL_VALUEHIGH_BOUND_VALUEHIGH_BOUND_INCL_VALUEDIMENSION_NAMEDIMENSION_ITEM_NAMENOTELAST_UPDATE_USERLAST_MOFIFIED_DATESTART_DATEEND_DATE
ALLMAP_SINGLE_VALUECurrent (0)NULLNULLNULLNULLDIM_SINGLE_VALUENOT DELINQUENTNULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_SINGLE_VALUECYC1. 1-30NULLNULLNULLNULLDIM_SINGLE_VALUECLASS 0NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_SINGLE_VALUECYC2. 31-60NULLNULLNULLNULLDIM_SINGLE_VALUECLASS 1NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_SINGLE_VALUECYC3. 61-90NULLNULLNULLNULLDIM_SINGLE_VALUECLASS 2NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_SINGLE_VALUECYC4. 90+NULLNULLNULLNULLDIM_SINGLE_VALUECLASS 3NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_SINGLE_VALUENPNANULLNULLNULLNULLDIM_SINGLE_VALUENPNANULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_SINGLE_VALUEDWONULLNULLNULLNULLDIM_SINGLE_VALUEDWONULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_SINGLE_VALUEDEFAULTNULLNULLNULLNULLDIM_SINGLE_VALUENOT IDENTIFIEDNULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL-1.00NULL-999.00DIM_BANDMISSINGNULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL0.00NULL0.00DIM_BANDZERONULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL1.00NULL50.00DIM_BANDFORCEDNULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL51.00NULL599.00DIM_BAND<600NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL600.00NULL619.00DIM_BAND600-619NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL620.00NULL639.00DIM_BAND620-639NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL640.00NULL659.00DIM_BAND640-659NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL660.00NULL679.00DIM_BAND660-679NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL680.00NULL699.00DIM_BAND680-699NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL700.00NULL719.00DIM_BAND700-719NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL720.00NULL739.00DIM_BAND720-739NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL740.00NULL759.00DIM_BAND740-759NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL760.00NULL779.00DIM_BAND760-779NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL780.00NULL799.00DIM_BAND780-799NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL800.00NULL819.00DIM_BAND800-819NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL820.00NULL839.00DIM_BAND820-839NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL840.00NULL859.00DIM_BAND840-859NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDNULLNULL860.00NULL1000.00DIM_BAND860+NULLNULLNULL2018-03-01 00:00:00NULL
ALLMAP_BANDDEFAULTNULLNULLNULLNULLDIM_BANDMISSINGNULLNULLNULL2018-03-01 00:00:00NULL

Constraints
SELECT PARAMETER_NAME,SINGLE_VALUE, count(*) FROM MPL_BI.REFERENCE_DATA_MAP
WHERE END_DATE IS NULL AND SINGLE_VALUE IS NOT NULL
GROUP BY PARAMETER_NAME,SINGLE_VALUE HAVING COUNT(*) > 1;

 
SELECT PARAMETER_NAME,LOW_BOUND_VALUE,LOW_BOUND_INCL_VALUE,HIGH_BOUND_VALUE,HIGH_BOUND_INCL_VALUE, count(*) FROM MPL_BI.REFERENCE_DATA_MAP
WHERE END_DATE IS NULL  AND (LOW_BOUND_VALUE IS NOT NULL OR LOW_BOUND_INCL_VALUE IS NOT NULL OR HIGH_BOUND_VALUE IS NOT NULL OR HIGH_BOUND_INCL_VALUE IS NOT NULL)
GROUP BY PARAMETER_NAME,LOW_BOUND_VALUE,LOW_BOUND_INCL_VALUE,HIGH_BOUND_VALUE,HIGH_BOUND_INCL_VALUE HAVING COUNT(*) > 1;

Apply for ETL
DROP TABLE MPL_BI.STG_TABLE IF EXISTS;
CREATE TABLE MPL_BI.STG_TABLE
(
 ACCOUNT int,
 DELQ CHARACTER VARYING(100),
 ORIGINAL_BUREAU_SCORE int
);
INSERT INTO MPL_BI.STG_TABLE VALUES (1,'Current (0)',-1);
INSERT INTO MPL_BI.STG_TABLE VALUES (2,'CYC1. 1-30',610);
INSERT INTO MPL_BI.STG_TABLE VALUES (3,'Other Value',NULL);
SELECT
 ACCOUNT,
 NVL(MAP_SINGLE_VALUE.DIMENSION_ITEM_NAME,MAP_DELQ_STATUS_COPS_0.DIMENSION_ITEM_NAME) AS MEMBER_DELQ,
 NVL(MAP_BAND.DIMENSION_ITEM_NAME,MAP_BUREAU_SCORE_20PT_BAND_INCLUDING_FORCED_0.DIMENSION_ITEM_NAME) AS MEMBER_ORIGINAL_BUREAU_SCORE
FROM MPL_BI.STG_TABLE S
LEFT JOIN MPL_BI.REFERENCE_DATA_MAP MAP_SINGLE_VALUE ON (MAP_SINGLE_VALUE.PARAMETER_NAME ='MAP_SINGLE_VALUE' AND S.DELQ=MAP_SINGLE_VALUE.SINGLE_VALUE)
LEFT JOIN MPL_BI.REFERENCE_DATA_MAP MAP_DELQ_STATUS_COPS_0 ON (MAP_DELQ_STATUS_COPS_0.PARAMETER_NAME ='MAP_SINGLE_VALUE' AND MAP_DELQ_STATUS_COPS_0.SINGLE_VALUE = 'DEFAULT')
LEFT JOIN MPL_BI.REFERENCE_DATA_MAP MAP_BAND ON (MAP_BAND.PARAMETER_NAME ='MAP_BAND' AND S.ORIGINAL_BUREAU_SCORE BETWEEN MAP_BAND.LOW_BOUND_INCL_VALUE AND MAP_BAND.HIGH_BOUND_INCL_VALUE)
LEFT JOIN MPL_BI.REFERENCE_DATA_MAP MAP_BUREAU_SCORE_20PT_BAND_INCLUDING_FORCED_0 ON (MAP_BUREAU_SCORE_20PT_BAND_INCLUDING_FORCED_0.PARAMETER_NAME ='MAP_BAND' AND MAP_BUREAU_SCORE_20PT_BAND_INCLUDING_FORCED_0.SINGLE_VALUE = 'DEFAULT');
 
 Apply for Cognos Dimensions
select * FROM MPL_BI.REFERENCE_DATA_MAP
WHERE PARAMETER_NAME IN ('MAP_SINGLE_VALUE')
AND DIMENSION_ITEM_NAME NOT IN (SELECT DELQ_STATUS from MPL_BI.DIM_CONFORMED_DELQ_STATUS);
select * FROM MPL_BI.REFERENCE_DATA_MAP
WHERE PARAMETER_NAME IN ('MAP_BAND')
AND DIMENSION_ITEM_NAME NOT IN (SELECT CURR_BUREAU_SCORE___20PT_BAND_INCLUDING_FORCED from MPL_BI.DIM_CONFORMED_BUREAU_SCORE_20PT_BAND_INCLUDING_FORCED);
 


No comments:

Post a Comment