Row Store Vs Column Store
Row Store Vs Column Store
Row Store Vs Column Store
Because computer memory is structured linearly, there are two options for
the sequences of cell values stored in contiguous memory locations:
Better Compression:
Columnar data storage allows highly efficient compression because the
majority of the columns contain only few distinct values (compared to
number of rows).
Conclusion:
To enable fast on-the-fly aggregations, ad-hoc reporting, and to benefit from
compression mechanisms it is recommended that transaction data is stored
in a column-based table.
The SAP HANA data-base allows joining row-based tables with column-based
tables. However, it is more efficient to join tables that are located in the
same row or column store. For example, master data that is frequently
joined with transaction data should also be stored in column-based tables.
Scheduling the SAP HANA Backups: 1651055
SAP HANA database backup and recovery: 1642148
Core Data Services are enhanced “view entities” in ABAP provides several advantages:.
The goal of ABAP CDS is to fully support the SQL-92 standard and beyond that to support
additional features likes associations, entities, create, read, update, and delete (CRUD) and OData
Services.
ABAP 7.4 SP05 support code to data paradigm. ABAP stack manages all entities and deploys all
artifacts from ABAP layer into the database layer. ABAP server act as master for developing,
managing and calling HANA views. On Activation of CDS views two objects are generated one
CDS Database View and other CDS entity. CDS views are defined for existing database tables,
any other views or CDS views in ABAP dictionary. Syntax for defining CDS view is similar to
SQL.
In the above example simple CDS view, “ZCDS_DDL_SAMPLE2” is CDS ABAP Database
View and “ZCDS_SAMPLE2” is CDS entity. CDS entity can be identified using “DEFINE
VIEW” syntax and CDS ABAP Database view can be identified using
“@AbapCatalog.sqlViewName” annotation which on activation accessible from SE11- ABAP
Dictionary View. Same applies to all the examples shown below.
In the new open SQL, ABAP CDS supports the CASE expression. It is also possible to nest cast
expression. An Alias name is required for the resulting column except for nested CASE. The
resulting column type is derived from expressions after THEN and ELSE clause.
Arithmetic expressions using operators +, - , *, & or the unary -, or using built in functions such
as CEIL( ) and MOD( ) are used. String expressions, including string concatenation operator &&,
or built in functions such as SUBSTRING( ) are used. Cast expressions are also supported.
Joins in CDS Views:
ABAP CDS support INNER joins, LEFT OUTER joins and RIGHT outer joins. Join conditions
can be inserted before or after the select list. Brackets are used to implement complex join
operators. When joins are used asterix is not supported in SELECT statements.
Annotations specify additional information such as how records of the view should be buffered
by ABAP table buffer, whether view is client dependent or not. By default CDS views are client
dependent and there is no need to include client fields explicitly in the field list or in the join
conditions.
Annotations are marked with the @sign on top of DDL source code in the view. In above
example @AbapCatlog.Buffering.status states whether buffering is switched off or active,
@AbapCatlog.Buffering.type states type of buffering for CDS view, @Semantics is used for
reference currency and quantity fields.
Simple and complex filtering conditions are supported. It is also possible to include WHERE
conditions in CDS view definitions.
Using the UNION and UNION ALL keywords views are merged from two or more queries. Here
UNION implies DISTINCT, the combined result contains no duplicate rows, UNION ALL
implies the combined result has duplicate rows.
When using the new Open SQL syntax you can used CDS View name which is identified using
DEFINE VIEW keyword in the select from clause. Note that CDS view name cannot have the
same name as the SQL view/ ABAP Dictionary view and the CDS view name also does not have
same name of the ABAP Dictionary.
Attribute Views in SAP HANA Modeling are created on the top of Dimension
tables. They are used to join Dimension tables or other Attribute Views. You
can also copy a new Attribute View from already existing Attribute Views
inside other Packages but that doesn’t let you change the View Attributes.
Choose the Package name under which you want to create an Attribute View.
Right Click on Package → Go to New → Attribute View
When you click on Attribute View, New Window will open. Enter Attribute
View name and description. From the drop down list, choose View Type and
sub type. In sub type, there are three types of Attribute views − Standard,
Time, and Derived.
Time subtype Attribute View is a special type of Attribute view that adds a
Time Dimension to Data Foundation. When you enter the Attribute name,
Type and Subtype and click on Finish, it will open three work panes −
Scenario pane that has Data Foundation and Semantic Layer.
Details Pane shows attribute of all tables added to Data Foundation
and joining between them.
Output pane where we can add attributes from Detail pane to filter in
the report.
You can add Objects to Data Foundation, by clicking on ‘+’ sign written next
to Data Foundation. You can add multiple Dimension tables and Attribute
Views in the Scenario Pane and join them using a Primary Key.
When you click on Add Object in Data Foundation, you will get a search bar
from where you can add Dimension tables and Attribute views to Scenario
Pane. Once Tables or Attribute Views are added to Data Foundation, they can
be joined using a Primary Key in Details Pane as shown below.
Once joining is done, choose multiple attributes in details pane, right click
and Add to Output. All columns will be added to Output pane. Now Click on
Activate option and you will get a confirmation message in job log.
Now you can right click on the Attribute View and go for Data Preview.
Note − When a View is not activated, it has diamond mark on it. However,
once you activate it, that diamond disappears that confirms that View has
been activated successfully.
Once you click on Data Preview, it will show all the attributes that has been
added to Output pane under Available Objects.
These Objects can be added to Labels and Value axis by right click and
adding or by dragging the objects as shown below −
Analytic View is in the form of Star schema, wherein we join one Fact table to
multiple Dimension tables. Analytic views use real power of SAP HANA to
perform complex calculations and aggregate functions by joining tables in
form of star schema and by executing Star schema queries.
Choose the Package name under which you want to create an Analytic View.
Right Click on Package → Go to New → Analytic View. When you click on an
Analytic View, New Window will open. Enter View name and Description and
from drop down list choose View Type and Finish.
When you click Finish, you can see an Analytic View with Data Foundation
and Star Join option.
Click on Data Foundation to add Dimension and Fact tables. Click on Star Join
to add Attribute Views.
Add Dim and Fact tables to Data Foundation using “+” sign. In the example
given below, 3 dim tables have been added: DIM_CUSTOMER,
DIM_PRODUCT, DIM_REGION and 1 Fact table FCT_SALES to Details Pane.
Joining Dim table to Fact table using Primary Keys stored in Fact table.
Select Attributes from Dim and Fact table to add to Output pane as shown in
snapshot shown above. Now change the data type of Facts, from fact table to
measures.
Click on Semantic layer, choose facts and click on measures sign as shown
below to change datatype to measures and Activate the View.
Once you activate view and click on Data Preview, all attributes and
measures will be added under the list of Available objects. Add Attributes to
Labels Axis and Measure to Value axis for analysis purpose.
Calculation Views are used to consume other Analytic, Attribute and other Calculation views
and base column tables. These are used to perform complex calculations, which are not
possible with other type of Views.
Choose the Package name under which you want to create a Calculation View. Right Click
on Package → Go to New → Calculation View. When you click on Calculation View, New
Window will open.
Enter View name, Description and choose view type as Calculation View, Subtype Standard
or Time (this is special kind of View which adds time dimension). You can use two types of
Calculation View − Graphical and SQL Script.
It has default nodes like aggregation, Projection, Join and Union. It is used to consume other
Attribute, Analytic and other Calculation views.
It is written in SQL scripts that are built on SQL commands or HANA defined functions.
Data Category
Cube, in this default node, is Aggregation. You can choose Star join with Cube dimension.
It does not allow base column tables, Attribute Views or Analytic views to add at data
foundation. All Dimension tables must be changed to Dimension Calculation views to use in
Star Join. All Fact tables can be added and can use default nodes in Calculation View.
Example
The following example shows how we can use Calculation View with Star join −
You have four tables, two Dim tables, and two Fact tables. You have to find list of all
employees with their Joining date, Emp Name, empId, Salary and Bonus.
Copy and paste the below script in SQL editor and execute.
Create column table Empfact2 (empId nvarchar(3), deptName nvarchar(20), Bonus integer );
Insert into Empfact2 values ('AA1','SAP', 2000);
Insert into Empfact2 values ('BB1','Oracle', 2500);
Insert into Empfact2 values ('CC1','JAVA', 1500);
Now we have to implement Calculation View with Star Join. First change both Dim tables to
Dimension Calculation View.
Create a Calculation View with Star Join. In Graphical pane, add 2 Projections for 2 Fact
tables. Add both fact tables to both Projections and add attributes of these Projections to
Output pane.
Add a join from default node and join both the fact tables. Add parameters of Fact Join to
output pane.
In Star Join, add both- Dimension Calculation views and add Fact Join to Star Join as shown
below. Choose parameters in Output pane and active the View.
Once view is activated successfully, right click on view name and click on Data Preview.
Add attributes and measures to values and labels axis and do the analysis.
It simplifies the design process. You need not to create Analytical views and Attribute Views
and directly Fact tables can be used as Projections.
Create 2 Attribute Views on 2 Dim tables-Add output and activate both the views.
Create 2 Analytical Views on Fact Tables → Add both Attribute views and Fact1/Fact2 at
Data Foundation in Analytic view.