Fact Data Mart Development

Data Mart development of a fact means creating a (snapshot) table with calculated/derived information serving as a place holder for a transaction source, i.e. the fact. There are two different Data Mart source types; one based on Materialized Views and one based on an ordinary table supported by incremental load.

This page deals with the source type Materialized Views. Data Mart development based on incremental load is found on a separate page named Incremental Load Development, valid both for dimensions and facts.

By connecting dimensions to the fact we get a Star Schema or an Information Source.

To publish the data in the Materialized Views a fact view has to be defined and then IFS Business Reporting & Analysis services specific metadata for the fact is defined and deployed.

This section provides some of the basic steps needed to create metadata support for a fact.

Note: It is recommended to always develop the Online and Data Mart access versions of a Fact. For more details about Online implementation please refer to the Online development page.

Note: All development of fact entities in IFS Applications should be done by using the IFS Developer Studio. The development is model based. Compared to a LU entity, a fact entity has a model file as well as generated files in the code repository. This is important to remember - never edit the fact files manually, instead always use the model.
For more information about how to handle modeling of a fact, please refer to IFS Develop Studio but also to the section about modeling.
The current page provides some details, things that can be good to know when developing a fact entity.

 

Contents

General MV Definition

If a fact does not support incremental load, then the storage container will be a Materialized View.

A Materialized View (MV) is a snapshot table that is created from a SELECT statement. When creating a MV for a fact, this is done by creating a PL/SQL block where the SELECT statement is executed dynamically. The block also contains creation of indexes.

The development work should be done by using IFS Developer Studio. A fact model is created/edited and when files are generated one entity specific file will be created representing the MV definition.

The following definition shows the basic template definition of a Materialized Views for a fact.


DECLARE
   stmt_                    VARCHAR2(32000);
   columns_                 Database_SYS.ColumnTabType;
   table_name_              VARCHAR2(30) := '&MV';
   index_name_              VARCHAR2(30);
   constraint_name_         VARCHAR2(30);
BEGIN

   dbms_output.put_line('Primary key cascade drop ON &MV');
   Database_SYS.Remove_All_Cons_And_Idx('&MV', TRUE);
   
   dbms_output.put_line('Drop Materialized View &MV');
   Database_SYS.Remove_Materialized_View('&MV', TRUE);

   dbms_output.put_line('Create Materialized View &MV');
   stmt_ :=
   'CREATE MATERIALIZED VIEW &MV 
    TABLESPACE &XXXXXX_MVIEW_DATA
    BUILD DEFERRED
    USING NO INDEX
    REFRESH COMPLETE ON DEMAND
    AS 
    SELECT  
      -- original key columns
            <key1_column>                             <key1_column_alias>,
            ...                                             ...,
            <keyN_column>                             <keyN_column_alias>,
      -- measure items
            <fact_attr1_column>                       <fact_attr1_column_alias>,
            ...                                             ...,
            <fact_attrN_column<                       <fact_attrN_column_alias>,
      -- light items
            <light_attr1_column>                      <light_attr1_column_alias>,
            ...,                                            ...,
            <light_attrN_column>                      <light_attrN_column_alias>,
      -- dimension identifiers
            <dimension1_id_columns>                   <dimension1_name>_id,
            ...                                             ...,
            <dimensionN_id_columns>                   <dimensionN_name>_id>,
      -- joiners
            <joiner1_column>                          <joiner1_column>,
            ...                                             ...,
            <joinerN_column>                          <joinerN_column>
    FROM <fact_source_table>
    WHERE <source_condition>';

   EXECUTE IMMEDIATE stmt_;

   dbms_output.put_line('Create constraints and indexes on Materialized View &MV');

   constraint_name_ := table_name_ || '_PK';
   Database_SYS.Set_Table_Column (columns_ , '<key1_column_alias>');
   ..
   Database_SYS.Set_Table_Column (columns_ , '<keyN_column_alias>');
   Database_Sys.Create_Constraint(table_name_,
                                  constraint_name_,
                                  columns_,
                                  'P',
                                  '&XXXXXX_MVIEW_INDEX',
                                  NULL,
                                  TRUE,
                                  TRUE);
   Installation_SYS.Reset_Column_Table(columns_);
   
   index_name_ := table_name_ || '_IX1';
   Database_SYS.Set_Table_Column (columns_ , '<dimension1_name>_id');
   Database_SYS.Create_Index( table_name_,
                              index_name_,
                              columns_,
                              'N',
                              '&XXXXXX_MVIEW_INDEX',
                              NULL,
                              TRUE,
                              TRUE);
   Installation_SYS.Reset_Column_Table(columns_);

   index_name_ := table_name_ || '_IX2';
   Database_SYS.Set_Table_Column (columns_ , '<dimension1_name>_id');
   Database_SYS.Set_Table_Column (columns_ , '<dimension2_name>_id');
   Database_SYS.Set_Table_Column (columns_ , '<dimension3_name>_id');
   Database_Sys.Create_Index( table_name_,
                              index_name_,
                              columns_,
                              'N',
                              '&XXXXXX_MVIEW_INDEX',
                              NULL,
                              TRUE,
                              TRUE);
   Installation_SYS.Reset_Column_Table(columns_);

END;
/   

Some remarks:

General Remarks

Some general remarks about Data Mart development for facts:

Deployment

Development of Data Mart support for a fact means creating a set of files that have to be deployed in the database.

The files are:

  1. Materialized View file definition
  2. Fact View file definition
  3. Fact Metadata file

Materialized View File

The Materialized View definition is either represented in a CRE file, an UPG file or as a part of a CDB file (bug correction).

The file is deployed in the database as any other CRE/UPG/CDB file.

IFS Developer Studio will only support creation of the CRE file. Also note that the CRE is entity specific.

When the Materialized View has been created, it is important to find out how long time it will take to perform a complete refresh and of course also to make sure that the selected data is correct.

A Materialized View is always empty after creation and the staleness is UNUSABLE. The Materialized View has to be activated first, i.e. the first snapshot has to be created. The Materialized View features in IFS Solution Manager can normally be used for activation, BUT these features are supposed to be used in an environment where all BI specific files have been deployed. So the suggested way to do the activation during development is to execute the following PL/SQL block in the database:

BEGIN
   Xlr_Mv_Util_API.Activate_Unusable_Mviews(<mview_name1>[,<mview_name2>,...,<mview_name3>]);
END;

After this step the natural thing would be to SELECT from the Materialized View to make sure that:

Testing refresh performance requires a large database.

The staleness (state) of a Materialized View can have many different values. Please refer to Materialized View Basics for more detailed information.

Fact View File

The fact view definition is represented as an APV file, meaning that it represents a public read interface.

The file is deployed in the database. Each entity has its own data mart view file.

After deployment the natural thing would be to SELECT from the view.

Make sure that:

Metadata File

A fact has to be described/defined in a metadata file. The metadata is represented as an INS file.

The file is deployed in the database as any other INS file. Each entity has its own metadata files.

Note: Always use the IFS Developer Studio to create/modify the model that in turn will be used to create the metadata file.

It is possibility to add/modify fact metadata in the Information Source feature but this is not recommended. Instead use IFS Developer Studio.

Note: If the Information Source feature is used to create or add metadata, it is important to make sure to export the metadata to file as the last step. Modifying the metadata via the Information Source feature means doing a customization in the current installation. If the changes are not saved and kept in an installation specific metadata file version, the manual changes will be overwritten next time the metadata is deployed, e.g. a new standard version of the file via a bug correction.

Information about the deployment is output on screen (or in log file). Errors must be investigated and corrected. Information lines should be looked up. Do one of the following:

When the accurate IMPORT_ID has been found, the following SELECT can be performed:

SELECT * FROM XLR_IMPORT_LOG_TAB WHERE IMPORT_ID = '<import_id>' ORDER BY LINE_ID ASC

When all errors have been corrected it is important to refresh the Materialized View Cache. The cache is vital for Materialized View related functionality in the IFS Business Reporting & Analysis services framework. There are two ways to do this:

Implementation Example

An implementation example related to a Data Mart version of a Fact can be found here.