Data Virtualization Lab

Learning Objectives:

In this tutorial you will learn:

  1. How to make a connection between external data sources & IBM CP4D connectors.
  2. How to query multiple data sources wihout creating data replicas using IBM Data Virtualization service.

Learning Outcome:

At the end of the workshop you will learn how to connects multiple data sources across locations by creating one virtual data view.

For this workshop, you have Covid-19 regional data stored in Amazon S3 and Amazon Aurora PostgreSQL data sources. In this workshop you will use IBM Data Virtualization Service to create virtual data view.

The proposed solution will solves data silos challenges faced by enterprises which force them to copy the data into centralized repository for analytics.

Prerequisites:

  1. IBM Cloud Pak for Data
  2. Data Virtualization on IBM Cloud Pak for Data
  3. External Data Sources (Amazon S3, Amazon Aurora PostgreSQL)
  4. IBM Watson Knowledge Catalog

Estimated time:

It should take you approximately 10-15 minutes to complete this lab.

Lab Steps:

Step 1: Login to IBM Cloud Pak for Data with valid credentials

To perform this lab you need IBM Cloud Pak for Data’s user credentials (eg. userxxxx) which you have created earlier. Credentials include both username and password. If you do not have the credentials then refer Infra Provisioning Lab exercise to get the credentials.

Login

Step 2: Create connection with AWS data sources using IBM CP4D connectors

In this lab, you will create connection with Amazon S3, and Amazon RDS data sources. Follow the below steps to create connection with those data sources:

  1. Click Navigation Menu -> Expand ‘Data’ and then click ‘Data Virtualization’

DV Menu

  1. In the Data Virtualization Page, Click Add connection + New Connection.

DV Homepage

Amazon Aurora Connection

  1. Select ‘Amazon RDS for PostgreSQL’ connection type and then click on Select.

Amazon Aurora Connection

You can also specify a connection name and other details as shown in below image then click Create to create Amazon RDS connection.

Amazon Aurora Connection Details Amazon Aurora Connection Details

  1. Click skip

Skip

  1. Similarly add Amazon S3 datasource by selecting connection type Amazon S3 and fill connection details provided using Infra Provisioning Lab. Similar to previous connection, You will have to specify the connection name and other required information such as Bucket, Endpoint URL, Region, Credentials (Shared, Basic).

  2. Once you create both data sources connection successfully, you should see both Amazon S3 and Amazon RDS PostgreSQL connection listed on the Data sources page as shown below.

Connection List

Step 3: Create virtual tables

Congratulations!

In the previous step you have successfully created connection between external data sources and Data Virtualization service. Now you can select tables and file from the connection and create virtualized tables or objects. Once tables are virtualized you can create a VIEW by joining two virtual tables.

  1. Open the Data Virtualization menu and click on Virtualization to expand and then click Virtualize as shown below.

Virtualize Menu

  1. Click on connection (eg Amazon RDS for PostgreSQL) and then you might see several tables under public schema.

If there are multiple connections listed, choose only one which you have created in previous step.

Create Virtual Table

Select the tables (ts_wallonia_region_table and ts_flanders_region_table) one by one and then click Add to cart. Once after adding both the tables to the cart, click View cart.

Create Virtual Table

  1. As shown in this screen, Select the Virtualize Data option and provide a unique name to table (in the image below names are ts_wallonia_region_table and ts_flanders_region_table).

You might need tables name in the next step. so, note it down for future reference.

Create Virtual Table Options

Now click on three dots and then click Edit columns option (eg ts_flanders_region_table) to verify name, type and length of the columns matches with image below and click Apply.

Create Virtual Table Options

Match the column name, type and length with the above image. Otherwise you may get error while creating View.

Repeat the same step for another table (here ts_wallonia_region_table).

Once after making the changes click Apply and then click Virtualize in Review cart and virtualize table page.

  1. Click Continue to create Virtual tables.

Create Virtual Table Confirmation

Click Virtualize more data option

Create Virtual Table Confirmation 1

  1. In the last step we Virtualized the tables coming from Amazon RDS connection, now let’s use csv file coming from Amazon S3 connection and Virtualize it. Click Files tab in the Virtualize page as shown below and then click Endpoint

Virtualize Menu

  1. Navigate to regional folder inside parent bucket and select ts-Brussels-grouped-21-04.csv as shown in below image and then click Add to cart then View Cart

Virtualize Menu

  1. In the Review cart and virtualize page specify unique name to the table and note it down for future reference, and then click Modify columns button to review columns metadata.

Virtualize Menu

  1. Edit the column name, type, and length as shown in below image and then click Apply

Match the column name, type and length with the below image. Otherwise you may get error while creating View.

Virtualize Menu

  1. In the Review cart and virtualize page check Virtualized data option then click Virtualize button.

  2. Click Continue to create Virtual tables.

Create Virtual Table Confirmation

  1. Click Go to virtualized data

Virtualize Menu

Step 4: Create VIEW by joining two virtual tables/objects

Till now we have created connections with external data sources and from external data sources we picked tables and files to Virtualize them. Now we will use those Virtualize tables/objects and join them to create a VIEW. This VIEW will give us capability to query multiple data sources without creating data replicas.

You can follow below steps to create VIEW:

  1. Click Data Virtualization menu and expand Virtualization and then click Virtualized Data option.

Virtualized Data Menu

  1. Select the virtual tables which you have created in the previous step. (eg here ts_wallonia_region_table and ts_flanders_region_table) and click Join.

You may see multiple tables, choose only those two that you have created.

Select Tables

  1. Join two tables by specify join key and then click Preview to preview joined table.

Select Tables

  1. Close preview page, click Next on Join virtual objects page

Select Tables

  1. Edit the column names as shown in below image. Make sure you have all column names in smallcase

Edit Column

  1. Once after ensuring all details, provide unique view name (eg. flanders_wallonia_joined_view), select Virtualized data checkbox and click Create view.

Select Tables

Click go to virtualized data

Select Tables

  1. Click ‘Virutalized Data’ and Select joined view you created in previous step (eg. flanders_wallonia_joined_view) and ts_Brussels-grouped-21-04_csv table to create view.

  1. Specify date as join Key and click Preview

  1. Edit the column names as shown below

  1. Specify the view name (eg. brussels_wallonia_flanders_joined_view) and click Create view

By following all the steps you have created a single joined view from different data source. Now let’s go to the Catalog to view the data.

  1. Click navigation bar and expand Catalogs and click All Catalogs and select default catalog to see the view we created in last step.

Select Tables

  1. In the Default Catalog page you will see the joined view (brussels_wallonia_flanders_joined_view) which you have created in the last step. If you noticed view started from ADMIN. which is the username. In your case, it might start with <USER_NAME>.brussels_wallonia_flanders_joined_view.

Click on the view for more details.

  1. Click Assets tab and provide your Cloud Pak for Data user credentials(userxxxx).

  1. After successfully validating credentials, you will be able to see the integrated data.

  1. Click on the Profile tab to get statistics of data inside view.

Summary

This lab you have learned how to use Data Virtualization on IBM Cloud Pak for Data to virtualize data and create merged VIEW to query multiple data sources without moving or copying the data. You have also learned how view can be exported to catalog and how IBM Watson Knowledge Catalog can generate statistics of the data inside view.