Breadcrumbs

10. Create Information Marts

The information marts are tables or views containing enriched data where the business rules can be applied. They are used by the end users or applications to take leverage of your data. The use cases are endless, but usually, they will be used for reporting purposes or to feed a new tool with enriched and trustful data.

In this tutorial, we will create a dimension for a simple star schema, which is documented here: Tutorial - 🗄️ IM contract

Create a snapshot

  1. Create a new snapshot for your information mart. It will contain the different points in time where you want to see your data.

    1. From the module “Distribute”, go to the “Snapshots” submodule

    2. Click on “Create Snapshot”

    3. Enter a name and select a type of snapshot (in this case “Load”)

    4. Click on “Save”

      image-20250930-190357.png


Create an information mart (IM)

To ease the navigation and access rights on the table and views distributed to the potential various sets of end users / products. We advise to create an IM for each set of use cases you are answering. E.g.: an IM covering the reporting based on current data only. an IM covering the results of the data quality controls, etc.

  1. Go back to Information Mart submodule and let’s create your information mart “Reporting”

  2. Click on 'Create an information mart

  3. Enter the following information (in the field ‘Snapshot group’, choose the snapshot that you created right before)

image-20250930-190449.png
  1. Click on save. You will see your information mart in the list

Create a dimension

  1. Let's create the car dimension Tutorial - Dimension Car

  2. Click on the button ‘Scripts’ in the row of your information mart

    image-20250930-190549.png
  3. Click on “Create a new script”

    1. A pop-up will appear. Enter the following information

image-20250930-190634.png
  1. Click on save. You will see your script in the list below your information mart

  2. Click on the button to open the script in a new tab

    image-20250930-190726.png
  3. A tab will open. It includes 3 sections

    1. Metadata

    2. Columns

    3. Code

  4. Go to the third section by clicking on the following symbol in the selection on the left of the tab

    image-20250306-132109.png
  5. Enter the following code

    DROP VIEW IF EXISTS im.dim_car CASCADE; --Drop the view in case it already exists. This way, you can edit the view in a future version
    CREATE VIEW im.dim_car AS
    SELECT 
    	hc.bk, 
        info.manufacturer ,
        info.model ,
        info.releasedate ,
        info.unitprice ,
        snap.snapshot_date
    FROM dv.h_car hc -- for a dimension, start with the hub 
    CROSS JOIN im.ctrl_dq snap -- to get the different points in time
    --join on the context satellite to get only car present in the source at a specific snapshot date
    INNER JOIN bv.h_car_crm_effsat eff ON eff.hk  = hc.hk AND snap.snapshot_date BETWEEN eff.load_dts AND eff.load_end_dts
    --Join on your satellite containing the descriptive information at the different snapshot dates
    INNER JOIN bv.v_sh_car_crm_info info ON info.hk  = hc.hk AND snap.snapshot_date BETWEEN info.load_dts AND info.load_end_dts 
    WHERE hc.bk IS NOT NULL -- to avoid having a ghost record in the dimension
      AND eff.src = 'crm' -- filter the context to get only the car from the CRM source
      AND snap.name = 'im' -- filter the snapshots to get only the one for your information marts 
    

    https://dfakto.atlassian.net/wiki/s/-2024114597/6452/d11bb6fdc5c8ba4c973785837de5a62b5833bfe3/_/images/icons/emoticons/warning.png In this example, we don’t use a pit table. It can be useful to use one to improve performance when reading data from the dimension when you have multiple satellites.

  6. Click on “Save”

  7. Go to the Version submodule, create a new version, and release it to an environment.
    It will make the script available for a worker that can be used in a state machine.

  8. Go to States, then “State Machines”

  9. Click on “Create State Machine”

  10. Enter the following definition:

    {
      "StartAt": "dim_car",
      "TimeoutSeconds": 6000,
      "States": {
        "dim_car": {
          "Type": "Task",
          "Resource": "ExecuteDataVaultQuery",
          "ResultPath": "$.Generated",
          "Parameters": {
            "QueryType": "Nonquery",
            "QueryName": "Reporting/dim_car",
            "EnvironmentName": "modeling",
            "ProjectName": "tutorial"
          },
          "End": true
        }
      }
    }
    


  11. Click on save

    image-20250619-151514.png
  12. Search your new state machine and execute it

  13. Your dimension is now created and available! If you go back in your database, you will be able to see the new view and the data in it.

    image-20230329-115150.png



That concludes our tutorial! You should have everything in your hand to be able to build a full beVault with the knowledge acquired here. You can still take a look at the user reference guide Reference Guide to know every little detail about each module.


Resolution

im.turoial.sql

State machine:

{
  "StartAt": "im-dim_cars",
  "TimeoutSeconds": 6000,
  "States": {
    "im-dim_cars": {
      "Type": "Task",
      "Resource": "ExecuteDataVaultQuery",
      "ResultPath": null,
      "Parameters": {
        "EnvironmentName": "modeling",
        "ProjectName": "tutorial",
        "QueryType": "Reader",
        "QueryName": "Global/dim_cars",
        "Type": "NonQuery",
        "CommandTimeout": 10
      },
      "Next": "im-dim_customers"
    },
    "im-dim_customers": {
      "Type": "Task",
      "Resource": "ExecuteDataVaultQuery",
      "ResultPath": null,
      "TimeoutSeconds": 10,
      "Parameters": {
        "EnvironmentName": "modeling",
        "ProjectName": "tutorial",
        "QueryType": "Reader",
        "QueryName": "Global/dim_customers",
        "Type": "NonQuery",
        "CommandTimeout": 10
      },
      "Next": "im-dim_contracts"
    },
    "im-dim_contracts": {
      "Type": "Task",
      "Resource": "ExecuteDataVaultQuery",
      "ResultPath": null,
      "TimeoutSeconds": 10,
      "Parameters": {
        "EnvironmentName": "modeling",
        "ProjectName": "tutorial",
        "QueryType": "Reader",
        "QueryName": "Global/dim_contracts",
        "Type": "NonQuery",
        "CommandTimeout": 10
      },
      "Next": "im-fact_contracts_details"
    },
    "im-fact_contracts_details": {
      "Type": "Task",
      "Resource": "ExecuteDataVaultQuery",
      "ResultPath": null,
      "TimeoutSeconds": 10,
      "Parameters": {
        "EnvironmentName": "modeling",
        "ProjectName": "tutorial",
        "QueryType": "Reader",
        "QueryName": "Global/fact_contract_details",
        "Type": "NonQuery",
        "CommandTimeout": 10
      },
      "Next": "im-dim_shops"
    },
    "im-dim_shops": {
      "Type": "Task",
      "Resource": "ExecuteDataVaultQuery",
      "ResultPath": null,
      "TimeoutSeconds": 10,
      "Parameters": {
        "EnvironmentName": "modeling",
        "ProjectName": "tutorial",
        "QueryType": "Reader",
        "QueryName": "Global/dim_shops",
        "Type": "NonQuery",
        "CommandTimeout": 10
      },
      "Next": "im-dim_employees"
    },
    "im-dim_employees": {
      "Type": "Task",
      "Resource": "ExecuteDataVaultQuery",
      "ResultPath": null,
      "TimeoutSeconds": 10,
      "Parameters": {
        "EnvironmentName": "modeling",
        "ProjectName": "tutorial",
        "QueryType": "Reader",
        "QueryName": "Global/dim_employees",
        "Type": "NonQuery",
        "CommandTimeout": 10
      },
      "End": true
    }
  }
}