In one of my previous articles, we discussed about synthetic keys (Synthetic keys in Qlikview – Simplified). We discussed why synthetic keys are generated and came to conclusion that if we have multiple synthetic keys in our data model, it might be a result of bad bad data model and may deliver unexpected results. We also saw a few ways to remove synthetic keys and improve our data model.
This article starts where we finished our last article. We will discuss two more techniques to remove synthetic keys and optimize our data model in our QlikView application. These two techniques are:-
Let’s understand these two techniques in detail using examples:
A sales oriented company has year on year transaction datasets (one dataset for each year) with one or two different fields (due to base system changes or defects) but rest of the fields are similar. Company wants to show YoY sales trends using these datasets.
In this scenario, let’s load all YoY datasets in QlikView. As you would expect, QlikView creates synthetic keys to join these tables, as these tables have multiple common fields. You can see the data model with synthetic key below. Now to remove synthetic key, we can’t rename/ drop all these fields because they are significant and related with each other. Here, we need all the fields in a table to show YoY trends, monthly seasonality over the year and many more things. As you know, Qlikview automatically concatenate/ combines tables if they have same granularity and columns. However, in our scenario, some of the columns are different. Here we need to force concatenation using CONCATENATE and combine the datastes in a single table (See Snpashot on the right).
Below, you can also see that in the SALES table, both Employee_Type and Branch_Type are appearing with their available values and total number of records is N1 (number of records in 2010) + N2 (number of records in 2011).
In similar manner, if the granularity and columns in the tables are same, then we can use Concatenate which will merge the tables into one and resulting table will have the sum of rows of the two tables.
To perform this we have five tables, in which two are fact table and others are dimension (Below is table structure).
Above you can see that tables, “Sales” and “Plan” have three common fields and Dimension tables are also associated with both the fact tables.
Now, if we load all these tables directly to QlikView, it will result in a data model with synthetic keys (screenshot below).
Since the fact tables do not have similar columns, we can not go for concatenation. At the same time, we need them for our analysis as well. Now to remove synthetic key in this data model we should use LINK table. It links two or more fact tables by taking all common fields out of the original tables and places them into a new table (called link table).The new link table contains all possible combinations of values for the set of fields through a unique key and is associated with the original tables.
In simple words, we can say that the link table replaces the synthetic key table and it has all the combinations of the key fields that are common for fact tables. We should also create a new compound key to connect all three tables (Two Fact tables and Link Table) and remove common fields from fact tables.
Rules to define Link Table:-
Now let’s look at the methods to develop data model using Link Table:-
Step – 1 Load facts table, form key for all common fields and comment all common fields.
Step – 2 Create the Link Table by loading the distinct values of the fact tables
Step-3 Load other dimension tables.
Step-4 Reload it and we would have following data model without a synthetic key.
Above, you can see a data model with Link table and it has all common fields of fact tables.
In the examples above, we looked at both the scenarios, where we should go with CONCATENATION or LINK table. Both methods have their own advantages, Let’s look at some of these:
As mentioned before, multiple synthetic keys typically reflects bad data model. We had looked at a few methods to remove synthetic keys in past. In this article, we particularly looked at two methods – LINK table and Concatenation. Both the methods have their own advantages and applications. The choice of method should depend on the business requirement and the kind of analysis required from the data.
Have you found this series useful? We have simplified a complex topic – Synthetic keys and have tried to present it in simple and understandable manner. If you need any more help Synthetic Key and Data model, please feel free to ask your questions through comments below..
Sunil Ray is Chief Content Officer at Analytics Vidhya, India's largest Analytics community. I am deeply passionate about understanding and explaining concepts from first principles. In my current role, I am responsible for creating top notch content for Analytics Vidhya including its courses, conferences, blogs and Competitions.
I thrive in fast paced environment and love building and scaling products which unleash huge value for customers using data and technology. Over the last 6 years, I have built the content team and created multiple data products at Analytics Vidhya.
Prior to Analytics Vidhya, I have 7+ years of experience working with several insurance companies like Max Life, Max Bupa, Birla Sun Life & Aviva Life Insurance in different data roles.
Industry exposure: Insurance, and EdTech
Major capabilities: Content Development, Product Management, Analytics, Growth Strategy.
Top 100 Data Science Interview Questions & ...
8 Must Know Spark Optimization Tips for Data En...
Synthetic Keys in Qlikview – simplified!
How to use VLOOKUP() like functionality in Qlik...
How to implement Incremental Load in QlikView?
Combining datasets in SAS – simplified!
Comprehensive Introduction to merging in SAS
How to re-use data models in Qlikview using Bin...
Understanding Dimensional Modeling
Difference Between Fact Table and Dimension Table
We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.
Show details
This site uses cookies to ensure that you get the best experience possible. To learn more about how we use cookies, please refer to our Privacy Policy & Cookies Policy.
It is needed for personalizing the website.
Expiry: Session
Type: HTTP
This cookie is used to prevent Cross-site request forgery (often abbreviated as CSRF) attacks of the website
Expiry: Session
Type: HTTPS
Preserves the login/logout state of users across the whole site.
Expiry: Session
Type: HTTPS
Preserves users' states across page requests.
Expiry: Session
Type: HTTPS
Google One-Tap login adds this g_state cookie to set the user status on how they interact with the One-Tap modal.
Expiry: 365 days
Type: HTTP
Used by Microsoft Clarity, to store and track visits across websites.
Expiry: 1 Year
Type: HTTP
Used by Microsoft Clarity, Persists the Clarity User ID and preferences, unique to that site, on the browser. This ensures that behavior in subsequent visits to the same site will be attributed to the same user ID.
Expiry: 1 Year
Type: HTTP
Used by Microsoft Clarity, Connects multiple page views by a user into a single Clarity session recording.
Expiry: 1 Day
Type: HTTP
Collects user data is specifically adapted to the user or device. The user can also be followed outside of the loaded website, creating a picture of the visitor's behavior.
Expiry: 2 Years
Type: HTTP
Use to measure the use of the website for internal analytics
Expiry: 1 Years
Type: HTTP
The cookie is set by embedded Microsoft Clarity scripts. The purpose of this cookie is for heatmap and session recording.
Expiry: 1 Year
Type: HTTP
Collected user data is specifically adapted to the user or device. The user can also be followed outside of the loaded website, creating a picture of the visitor's behavior.
Expiry: 2 Months
Type: HTTP
This cookie is installed by Google Analytics. The cookie is used to store information of how visitors use a website and helps in creating an analytics report of how the website is doing. The data collected includes the number of visitors, the source where they have come from, and the pages visited in an anonymous form.
Expiry: 399 Days
Type: HTTP
Used by Google Analytics, to store and count pageviews.
Expiry: 399 Days
Type: HTTP
Used by Google Analytics to collect data on the number of times a user has visited the website as well as dates for the first and most recent visit.
Expiry: 1 Day
Type: HTTP
Used to send data to Google Analytics about the visitor's device and behavior. Tracks the visitor across devices and marketing channels.
Expiry: Session
Type: PIXEL
cookies ensure that requests within a browsing session are made by the user, and not by other sites.
Expiry: 6 Months
Type: HTTP
use the cookie when customers want to make a referral from their gmail contacts; it helps auth the gmail account.
Expiry: 2 Years
Type: HTTP
This cookie is set by DoubleClick (which is owned by Google) to determine if the website visitor's browser supports cookies.
Expiry: 1 Year
Type: HTTP
this is used to send push notification using webengage.
Expiry: 1 Year
Type: HTTP
used by webenage to track auth of webenagage.
Expiry: Session
Type: HTTP
Linkedin sets this cookie to registers statistical data on users' behavior on the website for internal analytics.
Expiry: 1 Day
Type: HTTP
Use to maintain an anonymous user session by the server.
Expiry: 1 Year
Type: HTTP
Used as part of the LinkedIn Remember Me feature and is set when a user clicks Remember Me on the device to make it easier for him or her to sign in to that device.
Expiry: 1 Year
Type: HTTP
Used to store information about the time a sync with the lms_analytics cookie took place for users in the Designated Countries.
Expiry: 6 Months
Type: HTTP
Used to store information about the time a sync with the AnalyticsSyncHistory cookie took place for users in the Designated Countries.
Expiry: 6 Months
Type: HTTP
Cookie used for Sign-in with Linkedin and/or to allow for the Linkedin follow feature.
Expiry: 6 Months
Type: HTTP
allow for the Linkedin follow feature.
Expiry: 1 Year
Type: HTTP
often used to identify you, including your name, interests, and previous activity.
Expiry: 2 Months
Type: HTTP
Tracks the time that the previous page took to load
Expiry: Session
Type: HTTP
Used to remember a user's language setting to ensure LinkedIn.com displays in the language selected by the user in their settings
Expiry: Session
Type: HTTP
Tracks percent of page viewed
Expiry: Session
Type: HTTP
Indicates the start of a session for Adobe Experience Cloud
Expiry: Session
Type: HTTP
Provides page name value (URL) for use by Adobe Analytics
Expiry: Session
Type: HTTP
Used to retain and fetch time since last visit in Adobe Analytics
Expiry: 6 Months
Type: HTTP
Remembers a user's display preference/theme setting
Expiry: 6 Months
Type: HTTP
Remembers which users have updated their display / theme preferences
Expiry: 6 Months
Type: HTTP
Used by Google Adsense, to store and track conversions.
Expiry: 3 Months
Type: HTTP
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
Expiry: 2 Years
Type: HTTP
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
Expiry: 2 Years
Type: HTTP
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
Expiry: 2 Years
Type: HTTP
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
Expiry: 2 Years
Type: HTTP
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
Expiry: 2 Years
Type: HTTP
Save certain preferences, for example the number of search results per page or activation of the SafeSearch Filter. Adjusts the ads that appear in Google Search.
Expiry: 2 Years
Type: HTTP
These cookies are used for the purpose of targeted advertising.
Expiry: 6 Hours
Type: HTTP
These cookies are used for the purpose of targeted advertising.
Expiry: 1 Month
Type: HTTP
These cookies are used to gather website statistics, and track conversion rates.
Expiry: 1 Month
Type: HTTP
Aggregate analysis of website visitors
Expiry: 6 Months
Type: HTTP
This cookie is set by Facebook to deliver advertisements when they are on Facebook or a digital platform powered by Facebook advertising after visiting this website.
Expiry: 4 Months
Type: HTTP
Contains a unique browser and user ID, used for targeted advertising.
Expiry: 2 Months
Type: HTTP
Used by LinkedIn to track the use of embedded services.
Expiry: 1 Year
Type: HTTP
Used by LinkedIn for tracking the use of embedded services.
Expiry: 1 Day
Type: HTTP
Used by LinkedIn to track the use of embedded services.
Expiry: 6 Months
Type: HTTP
Use these cookies to assign a unique ID when users visit a website.
Expiry: 6 Months
Type: HTTP
These cookies are set by LinkedIn for advertising purposes, including: tracking visitors so that more relevant ads can be presented, allowing users to use the 'Apply with LinkedIn' or the 'Sign-in with LinkedIn' functions, collecting information about how visitors use the site, etc.
Expiry: 6 Months
Type: HTTP
Used to make a probabilistic match of a user's identity outside the Designated Countries
Expiry: 90 Days
Type: HTTP
Used to collect information for analytics purposes.
Expiry: 1 year
Type: HTTP
Used to store session ID for a users session to ensure that clicks from adverts on the Bing search engine are verified for reporting purposes and for personalisation
Expiry: 1 Day
Type: HTTP
Cookie declaration last updated on 24/03/2023 by Analytics Vidhya.
Cookies are small text files that can be used by websites to make a user's experience more efficient. The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies, we need your permission. This site uses different types of cookies. Some cookies are placed by third-party services that appear on our pages. Learn more about who we are, how you can contact us, and how we process personal data in our Privacy Policy.
Edit
Resend OTP
Resend OTP in 45s
Its really awesome. I have a doubt, Here why you are generating Key and Temp_Key fields, why you are dropping again, Shall we try with single column with the name of Key. Can you please explain.... @Sub2a
Hi Sunil Thanks for the info. I do have the similar situation 2 fact tables, opportunity and campaign where there are no common fields across these tables. I have opportunity create date in opportunity fact and campaign start date in campaign fact, where i need to derive common date calender. Could you please suggest me on the same. Thanks Satish
Hi Sunil, In the second approach(Link Table) we have three columns in Common between the two fact tables i.e. Employee_Id, Product_Code, Branch, what if we try the concatenation concept here.