So in order to expose the different layers and artefacts contained in this architecture see in the next picture and refer the numbers in the table below.

Data Architecture, Data Lake, Data Vault, Data Virtualization, Data governance and Data lineage

NumDescription
1Data source or Data Owners space. This could be Relational Database, API, Flat files, etc.
2Python customized script that will do all the ELT, capture audit information, feed the MDM (with Metadata automatically and configuration through operators) etc
3Layer where we will store all the data sets on its raw shape (just adding audit or ELT extra columns). Ideally it will be placed on Hive (Data Lake)
4When python (E)xtracts the source information into a file, then it loads it into Hadoop/Hive. This could be Delta or Full. This table is totally temporal, so it is not persistent.
5Now python will do the (L)oad. With our extra columns, we can hash the upcoming data and compare it through the Business Key to the one already stored in the History Stage (persistent) table. Then we will insert ONLY new and updated data. Later we will run a Delete Detection Pattern and insert the deleted Rows.
6This table is persistent and it will contain the initial full load and the inserted/deleted/updated new records on the following loads.
7The enterprise layer (or integration layer) is where our EDW will be located. Typically in Hive, but if needed could be stored anywhere else.
8Python will also load from our Raw Layer, the already modelled (through views ideally) data into a persistent EDW tables. In this case, we will apply only Hard Business Rules, which are the ones that not change the meaning of the data, just the shape. Example: Change data type, standardize Timestamps into a unique format, etc.
This data will land into what we called "Raw Data Vault". Modelled with DV 2.0 fashion, the data won't be agreegated or changed here.
9If required (optional) we will create out Business Data Vault, which could be views or another ELT to transform the data into more meaningful data for the business, where we will apply business rules, do aggregations, merge data, etc.
10This layer works on top of the DV layer. Because DV modelling is quite complex (even for some Data Engineers), this layer is meant to create (automatically if possible) a set of views with the information stored in RDV and BDV in a 3NF fashion (or even Star Schema fashion). So the Data consumers doesn't need to deal with the modelling complexity of DV2.0
11This Database with the output of EDW (DV) could be stored in Hive or Teradata or any other high performance database for later consumption. Ideally it will be just views or materialized views.
12This is our Data Virtualization space. From here we will choose a technology able to do cross platform queries and expose all our Raw Layer and EDW information through only this channel. Because the will connect to a simple JDBC or ODBC, they don't need to deal with the complexity of looking for data in Hive or in Teradata, etc. Everything will be simplified.
13We will apply Security and expose only the access level for that specific user (stored in MDM) creating views to the granted tables and columns. This database (in presto in our example) will need to regenerate all the views to follow the security specs stored in MDM or to capture new tables (also specified in MDM)
14Backbone of everything. Here we will stored the Metadata (refresh in every load), the patterns to use when loading, the extra configuration (blacklist columns/tables, identify delta fields) and also deal with the security to be exposed in the Presentation (or data Access layer)
15Audit database will track the data lineage of every single row and also stored information about the ELT and even, through presto, how many people are accessing which tables and how often. With this we can do a hot/warm/cold strategy.

Did you like this? Share it:

read more

Basically, if you keep your history just exposing the datetime when the record was inserted or updated, it is possible to get a view of your table in the shape of a Slowly Change Dimension Type 2. The way to achieve it is to mention your LoadDateTime as StartDate and then create a partition over the business key to identify the next LoadDateTime, and if there is no more, expose year 9999 or 2100 (no end). The following code will explain that in a real scenario. Note: ignore the audit fields that I used to create in the History Staging Area, which I will explain in my next post.

CREATE VIEW [hstg].[vw_Table_History]
AS
SELECT
ETL_EXECUTION_DT AS START_DATE,
ISNULL(lead (ETL_EXECUTION_DT) OVER (PARTITION BY  BusinessKey ORDER BY ETL_EXECUTION_DT), ‘9999-12-31 00:00:00.0000000’) AS END_DATE,
CASE WHEN lead (ETL_EXECUTION_DT) OVER (PARTITION BY BusinessKey ORDER BY ETL_EXECUTION_DT) IS NULL THEN ‘Y’  ELSE ‘N’ END AS [CURRENT_RECORD],
[BusinessKey],
[Field1],
[Field2],

ETL_BATCH_DT AS ETL_ROW_START_DT,
S.ETL_BATCH_ROW_ID,
CONVERT (DATETIME, ‘99991231’) AS ETL_ROW_END_DT,
ETL_ROW_HASH,
CONVERT (NVARCHAR (512), ‘AdvWorks’) AS ETL_ROW_SOURCE,
ETL_CDC_OPERATION,
ETL_EXECUTION_DT
FROM [hstg].[Table] S


Did you like this? Share it:

read more

Introduction

This is probably a key factor, technically speaking, of the future health of your BI solution. There is not perfect nor unique “Data Modelling” that will fit in ALL solutions, but there are some points that will power up your future DW and extend to the max. all the possibilities.

Data modeling it is so extensive concept that can’t be covered within one post neither one book, but we can provide some easy to understand “dos and don’ts” when creating your Staging Area and DW for reporting.

 

STAGING AREA

Prepare yourself for ANYTHING and get AS MUCH AS YOU CAN

This sentence is key if we are getting our data from the source to the staging area. Basically, we have to capture all the data from the source system, and keep record of the original modeling.

So it important to get all the Business Keys, Foreign Keys, nullable or non nullable fields attributes, etc. from the source system tables. And most important, record all the history at the same time. That means, every time we run our ETL, we need to bring all the data, and capture some audit columns in order to keep record of the history. So if at any point, there is a PK (or BK) that is changing in the source, we need to create another record in our Staging table with the CDC info, i.e.: INSERT/UPDATE/DELETE

That will create a database with the data as it is in the source system, adding some audit fields and history, so at any point in time we can recreate our DW using its history and we won’t miss anything out.

Dos:

  • * Raw data in Stage, respecting the DDL (datatypes, fields, etc.)
  • * Get any table that might be a potential for your interest. The DB space/resources are limited, so I won’t say get EVERY single tables no matter what, but if possible, that is not a bad idea.
  • * Keep history, so you can recreate your DW and Datamarts easily in the future.

Don’ts:

  • * Don’t change data, like computing or merging two fields (i.e.: name + surname = full name)
  • * Don’t crop or truncate any fields. If you thing a datatype of VARCHAR(2000) is too big, keep that length in your staging or even round it up to 4000 or MAX.
  • * Don’t start modeling or “fixing” the data model in your Staging Area, even if it looks wrong, you should respect this DDL at this stage, that is something you’ll start working on the next phase, while moving data to DW or even better, to your presentation layer.

 

DATA WAREHOUSE

For our Data Warehouse I can’t recommend a unique model, as every solution/business is different, and the purpose of this DW could be Archiving, reporting, build a base for OLAP/Tabular cubes and so on.

The most extended and well known models are:

 

3NF

Pro

  • save most storage of all modelling techniques
  • simple to understand

Con

  • bad performance with multiple joins
  • difficult to load (ETL)
  • changes are very difficult to handle

 

* Star Schema

Pro

  • Simple design
  • fast queries
  • fits very well to olap models
  • many DBMS are optimized for queries on star schemas

Con

  • usually centralized on one fact table
  • higher storage usage due to denormalization

 

My suggestion is, to use “Data Vault” http://en.wikipedia.org/wiki/Data_Vault_Modeling in the DW core and from that point you can build star schemas in data marts. To explain the benefits of DV would take more than 1 post, so if you are really interested, just Google it or have a look at the Wikipedia link I provided.

Cheers!

 

 


Did you like this? Share it:

read more

The purpose of this post is to clarify some basics on the SSAS Tabular Cubes and how we can apply Incremental updates in order to achieve RealTime and its best practice.

 

First of all it is important to know about the basic processing options on Tabular cubes:

 

Object Available Processing Options
Database Process Clear, Process Default, Process Defrag, Process Full, Process Recalc
Table Process Clear, Process Data, Process Default, Process Defrag, Process Full
Partition Process Add, Process Clear, Process Data, Process Default, Process Full

 

And the meaning of these processing options:

 

Processing Option Description
Process Add Adds new rows to a partition. Any affected calculated columns, relationships, user hierarchies, or internal engine structures (except table dictionaries) are recalculated.
Process Clear Drops all the data in a database, table, or partition.
Process Data Loads data into a partition or table.
Process Default Loads data into unprocessed partitions or tables. Any affected calculated columns, relationships, user hierarchies, or internal engine structures (except table dictionaries) are recalculated.
Process Defrag Optimizes the table dictionary (an internal engine structure) for a given table or for all tables in the database*. This operation removes all dictionary entries that no longer exist in the data set and rebuilds the partition data based on the new dictionaries.
Process Full Loads data into all selected partitions or tables. Any affected calculated columns, relationships, user hierarchies, or internal engine structures (except table dictionaries) are recalculated.
Process Recalc For all tables in the database, recalculates calculated columns,  rebuilds relationships. rebuilds user hierarchies, and rebuilds other internal engine structures. Table dictionaries are not affected.

 

Once we have a clear idea of all the options we can apply in our BI Lifecycle we must differentiate between the concept that update or refresh your database doesn’t mean real update DWH:

 

  • Recalculate (Process Recalc) is not going to add new info, it is going just to recalculate all the measures even if you don’t insert new data in your cube.

 

  • Partitioning is a very common and old practice used mainly in the big solutions (huge amount of rows) where you need to process some old part of your BI solution only once and that’s not going to change. i.e.: sales 2005, 2004, 2003… In order to define your partitions you are flexible enough to specify a query that will bring only part of the table to these partitions, like “WHERE ID_Dim_Date >= 20010101 and ID_Dim_Date <= 20021231” where your current partition will have something like “WHERE ID_Dim_Date > 20130101” . That could be an option to only process part of your data, but it is not the best practice because you have to define your partitions which they’ll be at the Year or Month level, that means, if you have to re-process your 2013-11 partition every 5 minutes to aim realtime data.

 

  • Incremental processing (Process Add) is the one to achieve your beloved real-time. It will do the deltas by itself, adding or updating whatever just changed. Sadly, you can’t specify a query to apply the deltas only for an specific period.

 

Best Practice:

The ideal scenario is to use the process Add but not using the whole table (reducing the amount of data to process). Hence we can use a Partition, let’s say for 2013-11 and on top of that, ProcessAdd, which will keep and process very quickly the deltas. Then you can re process the cube as many times as you need and getting closer to what we call “real time”.


Did you like this? Share it:

read more

BIML (Business Intelligence Markup Language)

BIML is a Markup Language created by Variance which will help you to automatize the creation of many assets in your BI solutions, like SSIS packages or Cube (SSAS) definitions. For better definition visit Wikipedia http://en.wikipedia.org/wiki/Business_Intelligence_Markup_Language

As you may know, all the metadata of your MS BI suite is based on XML. If you take any cube or dtsx package and open it with Notepad you’ll notice that everything inside is XML. BIML is a tool to autogenerate this XML code through .Net or even SQL. You can find samples and all the possible tags to use on http://bimlscript.com/.

Based on that, I created on SQL Stored Procedure a what I called “PackageGenerator”. This SP will ask for an IDPackage and this ID will lead to a series of simple configuration tables that will define your DTSX Source, Target, fields, transformations, etc. In order to Autogenerate the package into your VS Solution with just one right click -> Generate.

Datavalut + BIML

As I explained before Datavault is a flexible  DWH following a rigid standards that will allow you to “guess” how a new entity will be build (more info check my previous post http://www.businessintelligence-solutions.com/dv-datavault-approach-dwh/). For example, we know that the business key will be on a Hub, and we know that all the hubs start with H_[EntityName]. Then if you have any link you know that it will be allocated in a Link and all the links (one or more) will be structured like this L_[EntityName]_L1,L_[EntityName]_L2… and same for Satellites S_[EntityName]_S1,S_[EntityName]_S2,…

Then you also know from the very beginning that all your tables will have a standardized structure and fields as… ValidFrom, ValidTo (always in all the tables and allowing you to do a SCD2 by default), RecordSource (to know from where is coming the data) and LoadDateTime (to know when it was inserted).

Then each object has a link to the hub always H_[EntityName]_SK (int) and your hub will always containt (apart of this unique SK) the business key called H_[EntityName]_BK.

With all these rules in place, you can create a framework that will allow you (hopefully with a UI created on top of that) to create all your BIML packages using this SP that will be feed by all these tables:

Then now the possibilities are open to almost everything. For example, in less than a week a prepare a SP that will call (thanks to these tables or even to the system tables that you can query) your DW. You just need to define which ones are going to be Dimensions, which ones Fact tables and your SP will recreate the whole DW (drop and create). It will link your fact tables (through constraints) to your dimensions, it will create all the tables with the same rules (ID_Dim_, or ID_Fact_…). And of course, it will create automatically all the dtsx to bring the data from your DV to your dimensional modelling in seconds and also the views that will wrap all these H, S and L into one Dim or Fact (depending what you said in your tables), besides I have a table that will define SCD1 or SCD2 and your system will create the dtsx doing an update or doing a SCD (http://www.businessintelligence-solutions.com/practice-scd-ssis/).

The weak point of DV is that usually a normal third normal form database that has around 30 tables in DV it will become more than 120+, but using BIML on top of your DV it will create the 120+ packages (dtsx) in seconds and your DW will change as soon as you really need it without any problem.

Good luck!
Albert


Did you like this? Share it:

read more