Database table is the most common way to model decision tables. Users are accustomed to column-based business rules which are simpler to create and easy to transform for consumption. Even though the database tables can be the first step to prepare decision tables, there are also users who are already familiar with HANA modeling views like Attribute View, Analytical View, Calculation View etc. and would want to design rules based on these views. In this section we target these users and explain how to model decision table using information views and its advantage.
Each SAP HANA modeling view is designed for specific purpose and is efficient when used in that context like Analytical View is best suited for analyzing – calculation and aggregation – of the data that is arranged in star-like-schema. This is done by different set engines in HANA like JOIN engine is used for Attribute view, Calculation Engine is used for Calculation views etc. These engines are optimized to produce best results in quick time.
To leverage the high performance capabilities of these engines, users may choose to model these views first and then use them to write business rules in form of decision tables. By default the Decision Table would be executed by Join Engine. If the decision table is designed on the modeler views, then it is executed by their respective engine that are already optimized to provide improved performance.
With assumption that you already know how to work with modeling view, let us start with designing decision table using modeling views. For this example, I have picked Analytic view which has an aggregation (SUM) to calculate the sales of a particular electronic gadget. This view we use in decision table to give DISCOUNT on the products.
First model analytic view using ORDER and PRODUCT database tables. Things to mark –
- QUANTITY is aggregated as SUM
Note the columns selected from the two tables to model Analytic view. These are regarded as Output of the Analytic view.
Figure 4.1 – Overview of the Analytical View modeled on ORDER and PRODUCT tupes. This Analytical view will be later used to model decision table
Next, design decision tables on this Analytic view. Things to mark –
- The Output of the Analytic view appear as options to model the decision table
Figure 4.2 – Data Foundation with Analytical view and the Output view showing the Condition and Actions columns
Fill the decision table with values –
Figure 4.3 – Decision table with values
Finally, Save Validate and Activate the decision table. Your decision table is now ready for consumption. As already explain – call the generated procedure for the respective decision table. Few things to mark here are –
- QUANTITY is aggregated as SUM in original Analytic view
- When QUANTITY column is used in Decision Table – it is equivalent to SUM of QUANTITY column
- OLAP engine – which is meant to handle efficiently aggregation and other calculation based on start schema – is used when decision table is executed. In the first screenshot below you see some contents from ORDER table marked as RED – these are those Auzuroà Handset product which is mentioned in the decision table.
- In the second screenshot below – you would notice that QUANTITY values – for each product -are summed from the database content like Auzuro àHandset (PRODUCT ID: SAM_1000123) has 5 entries with SUM(QUANTITY) = 18. Similarly Mattle àMobile (PRODUCT ID: APP_1000124) has 3 entries with SUM(QUANTITY) = 22 etc.
- Finally you see DISCOUNT updated for only Auzuroà Handset product as per the decision table
Figure 4.4 – Content of ORDER tuple (top) and SQL Editor with call statement (below) showing the decision table comsumption
As Parameter is used in the Action, the result set is a simulated result – and do not modify the DISCOUNT column values of the original database table i.e. ORDER. Let me finally summarize the steps again –
- Create one of the modeler view – Attribute, Analytical or Calculation view
- Create Decision table in HANA Studio
- Drag and Drop these view onto Data Foundation section
- Select Output of the modeler view as Conditions and Actions columns of the decision table
- Set the values of Condition and Action
- Save, Validate and Activate
For more refer http://help.sap.com/hana_platform > HANA Developers Guide > Setting up the Analytical Model > Creating Decision Tables
Thus, decision table can be designed on modeler view and efficiently addresses the performance bottlenecks which might occur with use of database tables. However, an initial knowledge and recommendations on working with modeling views is required to completely utilize the specialization, parallelization and performance optimizer capabilities of these engines.
Other Related Blogs
- Introduction – Big Data Decision Making using Decision Tables
- Decision Table in SAP HANA – Concept
- Getting Started – Model simple decision table
- Decision Table on HANA Database Tables
Upcoming Blogs in Store