opensap hana1 week 02 database tasks loading modeling
DESCRIPTION
OpenSAP HANA1 Week 02 Database Tasks Loading ModelingTRANSCRIPT
Week 2 Unit 1: Database Schemasand Database Tables
© 2013 SAP AG. All rights reserved. 2Public
Database Schemas and Database TablesThe SAP HANA Repository
Object management, versioning,and transport
Software component deliveryand patching
Built-in support for translatabletexts
Support for server-baseddevelopment
© 2013 SAP AG. All rights reserved. 3Public
Database Schemas and Database TablesThe SAP HANA Repository
Presentation logic
Control flow logic
Calculation logic
Client
Data Data artifacts
Control flow artifacts
Presentation artifacts
HANA
Manage all artifacts in onerepository
Presentation (UI)
Control flow (Application)
Data persistence:TablesViewsSchemas…
© 2013 SAP AG. All rights reserved. 4Public
Database Schemas and Database TablesData Persistence in SAP HANA
Data persistence objects
Schemas
Tables
SQL views
Sequences
Procedures
…
© 2013 SAP AG. All rights reserved. 5Public
Database Schemas and Database TablesDatabase Schemas for SAP HANA
Database object
Mandatory
Contains logical groups:TablesViewsProceduresSequences…
© 2013 SAP AG. All rights reserved. 6Public
Database Schemas and Database TablesDesign-time Schemas for SAP HANA
Design-time object
Transportable
Plain text file
Mandatory file suffix(.hdbschema)
Repository activationcreates runtime object inthe catalog
© 2013 SAP AG. All rights reserved. 7Public
Database Schemas and Database TablesDesign-time Schemas: Configuration Syntax (.hdbschema)
Mandatory syntax(.hdbschema)
Schema name keyword
Schema name
Authorizations
© 2013 SAP AG. All rights reserved. 8Public
Database Schemas and Database TablesDatabase Tables for SAP HANA
Database object<package.path>::<TableName>
A set of data elements
Type:ColumnRow
Metadata:Constraints on tableConstraints on values in particularcolumns…
© 2013 SAP AG. All rights reserved. 9Public
Database Schemas and Database TablesDesign-time Tables for SAP HANA
Design-time object
Transportable
Plain text file
Mandatory file suffix(.hdbtable)
Repository activationcreates runtime object inthe catalog
© 2013 SAP AG. All rights reserved. 10Public
Database Schemas and Database TablesDesign-time Tables: Configuration Syntax (.hdbtable)
Mandatory syntax(.hdbtable)
Schema name
Table typeColumn/Row…
Table columnsName, SQL type, length…
Data typesNVARCHAR, DATE, DECIMAL…
Primary key
Week 2 Unit 2: Sequences andSQL Views
© 2013 SAP AG. All rights reserved. 2Public
Sequences and SQL ViewsDatabase Sequences for SAP HANA
Database object<package.path>::<SequenceName>
Generates an incremented list ofnumeric values
Ascending/descending order
Used by applications to:Reference sequence objectsGenerate primary key valuesIdentify table columns/rowsCoordinate keys across rows/tables
© 2013 SAP AG. All rights reserved. 3Public
Sequences and SQL ViewsDesign-Time Sequences for SAP HANA
Design-time object
Transportable
Plain text file
Mandatory file suffix(.hdbsequence)
Repository activationcreates runtime object inthe catalog
© 2013 SAP AG. All rights reserved. 4Public
Sequences and SQL ViewsDesign-Time Sequences: Configuration Syntax (.hdbsequence)
Mandatory syntax.hdbsequence
Keywords:schemastart_withnomaxvaluenominvaluecyclesdepends_on_tabledepends_on_view
Usage:SQL Insert (NEXTVAL)
© 2013 SAP AG. All rights reserved. 5Public
Sequences and SQL ViewsSQL Views for SAP HANA
Database object<package.path>::<ViewName>
SQL statements/queries
Join data from different tables
© 2013 SAP AG. All rights reserved. 6Public
Sequences and SQL ViewsDesign-Time SQL Views for SAP HANA
Design-time object
Transportable
Plain text file
Mandatory file suffix(.hdbview)
Repository activationcreates runtime object inthe catalog
© 2013 SAP AG. All rights reserved. 7Public
Sequences and SQL ViewsDesign-Time SQL Views: Configuration Syntax (.hdbview)
Mandatory syntax
Schema name
SQL query:JSON notation (\”Name\”)Select fromleft outer join onorder bydepends_on_table/view
Joined table names:<package.path>::header<package.path>::item
Week 2 Unit 3: Authorizations
© 2013 SAP AG. All rights reserved. 2Public
AuthorizationsAvailable Active Roles: Overview
Default Roles:CONTENT_ADMINMODELINGPUBLIC
Imported Roles:<PackagePath>::<RoleName>sap.hana.xs.admin::administratorsap.hana.xs.admin::viewersap.hana.ui5.db::SITE_DESIGNERsap.hana.ui5.db::SITE_USER
© 2013 SAP AG. All rights reserved. 3Public
AuthorizationsBuilding Repository Roles: Create
Design-time object
Transportable
Plain text file
Mandatory file suffix (.hdbrole)
Repository activation creates runtimeobject in the catalog
© 2013 SAP AG. All rights reserved. 4Public
AuthorizationsBuilding Repository Roles: Define
Role name
Extends another role
Privileges:SchemaSELECT, INSERT, UPDATE,DELETE, DROP…Application:ADMIN (EXECUTE, SAVE…)– System– SQL objects– Packages– Analytic
Commit/Activate
© 2013 SAP AG. All rights reserved. 5Public
AuthorizationsBuilding Repository Roles: Grant Activated Role to a User
Grant role with_SYS_REPO procedure:
GRANT_ACTIVATED_ROLE
Grant parameters’ROLENAME’’USERNAME’
SQL procedure call
Week 2 Unit 4: EPM Demo Schema
© 2013 SAP AG. All rights reserved. 2Public
EPM Demo SchemaAvailable EPM Demo Data
The EPM demo data includes thefollowing catalog objects:
Tables
Views
Sequences
Synonyms
© 2013 SAP AG. All rights reserved. 3Public
EPM Demo SchemaEPM Demo Data: Tables
A table is a set of data elements thatare organized using columns androws.
EPM Tables:AddressesBusiness partnersEmployeesProductsSales orders…
© 2013 SAP AG. All rights reserved. 4Public
EPM Demo SchemaEPM Demo Data: Views
A view is a virtual table based on thedynamic results returned in responseto an SQL statement.
EPM ViewsPurchaseOrderHeaderExt
© 2013 SAP AG. All rights reserved. 5Public
EPM Demo SchemaEPM Demo Data: Sequences
A sequence is a database object thatgenerates an automaticallyincremented list of numeric values toidentify tables, columns, or rows.
EPM Sequences:Address IDEmployee IDPartner IDPurchase Order IDSales Order IDText ID
© 2013 SAP AG. All rights reserved. 6Public
EPM Demo SchemaEPM Demo Data: Synonyms
A synonym is an alternative name fora database table.
EPM Synonyms:TCURCTCURFTCURNTCURRTCURTTCURVTCURW…
Week 2 Unit 5: Single File DataLoad of CSVs
© 2013 SAP AG. All rights reserved. 2Public
Single File Data Load of CSVsAutomatic Table Data Load: Required Files
CSV fileHolds data, separated bycommas, to load into target table
Table Import ModelDefines target DB table for loadMandatory file suffix (.hdbtim)
Table Import DataConnects CSV file to data loadmodel file (.hdbtim )Mandatory file suffix (.hdbtid)
© 2013 SAP AG. All rights reserved. 3Public
Single File Data Load of CSVsAutomatic Table Data Load: Source File
Data source file
Transportable, design-timeobject
Contains the values to loadinto the database table
Values separated by commas
Number of columns in CSVfile/ target table must match
Data types in target table/CSVcolumns must match
© 2013 SAP AG. All rights reserved. 4Public
Single File Data Load of CSVsAutomatic Table Data Load: Import Model
Table import model file
Design-time object
Transportable
Mandatory file suffix(.hdbtim)
Specifies source file type
Defines the target table inthe database (“item”)
© 2013 SAP AG. All rights reserved. 5Public
Single File Data Load of CSVsAutomatic Table Data Load: Import Data
Table import data file
Design-time object
Transportable
Mandatory file suffix (.hdbtid)
Connects the CSV source file tothe data load model file
Specifies the source CSV file
© 2013 SAP AG. All rights reserved. 6Public
Single File Data Load of CSVsAutomatic Table Data Load: SQL Query to View Results
SELECTTOP 1000 *
FROMSchema nameWORKSHOPX_00Namespaceworkshop.sessionx.00.dataObject delimiterdouble colon (::)Table nameitem
Week 2 Unit 6: Attribute Views
© 2013 SAP AG. All rights reserved. 2Public
Attribute ViewsOverview
Attribute views:Model an entity based uponrelationships of multiple sourcetables
Can contain:ColumnsCalculated columnsHierarchies
© 2013 SAP AG. All rights reserved. 3Public
Attribute ViewsDefining Sources and Relationships
Define an attribute view:
SourcesThe main components of anattribute view are tables.
RelationshipsJoin fields in tables to get aconsistent definition of theoverall entity.
© 2013 SAP AG. All rights reserved. 4Public
Attribute ViewsDefining the Output Structure
Example:Tables often contain alarge number ofcolumns.Add only the columnsyou really need in theoutput structure.
Output structureField selection
© 2013 SAP AG. All rights reserved. 5Public
Attribute ViewsDefining Field and Column Properties
The properties of a view columnaffect the overall usage:
Key AttributeDrilldown-EnabledHidden
© 2013 SAP AG. All rights reserved. 6Public
Attribute ViewsDefining Calculated Output Fields 1
To define a new calculatedoutput field that is based onexisting fields in the view,you can use:
Other output fields
Formulas
Conversion (unit of measureand currency)
© 2013 SAP AG. All rights reserved. 7Public
Attribute ViewsDefining Calculated Output Fields 2
To define a new calculatedoutput field, you must specify:
The data type
The field width
The scale
The rule definition
© 2013 SAP AG. All rights reserved. 8Public
Attribute ViewsData Preview
Preview the datadisplayed by the view
© 2013 SAP AG. All rights reserved. 9Public
Attribute ViewsData Preview with Analysis
Week 2 Unit 7: Analytic Views
© 2013 SAP AG. All rights reserved. 2
Analytic ViewsOverview
Analytic Views:Leverage the computing power ofSAP HANA to calculate aggregatedataContain two types of columns– Attributes– Measures
© 2013 SAP AG. All rights reserved. 3
Analytic ViewsSet Parameters
Assign a unique name forthe technical name of theanalytic view
Change the view type toAnalytic View
© 2013 SAP AG. All rights reserved. 4
Analytic ViewsDefinition of Data Foundation and Logical Joins
Explanation of terms:
Data Foundation:Represents the tables used for defining thefact table of the view
Logical Join:Represents the relationship between theselected table fields (fact table) andattribute views
© 2013 SAP AG. All rights reserved. 5
Analytic ViewsData Foundation View
The Data Foundation viewshows all the fields that canbe incorporated into thefinal model.
These fields are marked asoutput fields
© 2013 SAP AG. All rights reserved. 6
Analytic ViewsLogical Join
The Logical Join viewdisplays only thosefields you have chosento include in this model,as well as the restrictedand calculatedmeasures that havebeen defined.
© 2013 SAP AG. All rights reserved. 7
Analytic ViewsSemantics View
In the Semantics view,you can classify thecolumns andcalculated columns asattributes andmeasures.
You can also createvariables/inputparameters andhierarchies andassign variables to thecolumns.
© 2013 SAP AG. All rights reserved. 8
Analytic ViewsCalculated Columns
There are many options for defining acalculated measure:
Aggregation, such as sum, minimum,maximum, and countData types, such as decimals, numbers,and so onExpressions or operatorsString, date math, conversion, and so on
© 2013 SAP AG. All rights reserved. 9
Analytic ViewsRestricted Columns
The restriction for a measure is basedon an attribute value.
In the example, the measureRC_PRODUCT_CAT_NOTEBOOKSshows only Gross Amount valuesfrom the Product Category‘Notebooks’.
© 2013 SAP AG. All rights reserved. 10
Analytic ViewsData Preview
The same options existhere as exist for theattributes view:
Raw dataDistinct valuesAnalysis
Week 2 Unit 8: Calculation Views
© 2013 SAP AG. All rights reserved. 2Public
Analytic View
View or Table
Join
Calculation ViewsTwo Types
© 2013 SAP AG. All rights reserved. 3Public
Calculation ViewsView Creation Wizard
Assign a unique name must bealphanumeric (A-Z; 0-9; _)
Select Graphic or SQLScript
© 2013 SAP AG. All rights reserved. 4Public
Calculation ViewsSelecting Components
Select any tables, attributeviews, or analytic views toadd to the Calculationview.
© 2013 SAP AG. All rights reserved. 5Public
You can add projection nodes to addextra fields. For example, adding thecurrency converted amount field
Calculation ViewsSelecting Components
© 2013 SAP AG. All rights reserved. 6Public
Choose the fieldsthat should beavailable for thenext level
Calculation ViewsOutput Definition
© 2013 SAP AG. All rights reserved. 7Public
Calculation ViewsCalculated Column
© 2013 SAP AG. All rights reserved. 8Public
Calculation ViewsDefine Union
© 2013 SAP AG. All rights reserved. 9Public
Calculation ViewsScripted Views Overview
DB Layer
Code
Traditional:“Data to Code”
New Model:“Code to Data”
Massive datacopies create
bottleneck
Transferminimumresult set
Application LayerApplication Layer
DB LayerCode
© 2013 SAP AG. All rights reserved. 10Public
Calculation ViewsDefine Output Structure, Define Function and SQLScript
© 2013 SAP AG. All rights reserved. 11Public
Calculation ViewsDefine Which Columns are Attributes or Measures
You need to selectthe attributes andmeasures for theoutput node.
Week 2 Unit 9: Analytic Privileges
© 2013 SAP AG. All rights reserved. 2Public
SQLprivilege
SYSTEMprivilege
Packageprivilege
Analyticprivilege
Analytic PrivilegesTypes of Privileges
When you access the SAP HANA database, ensure that any access to data isbacked by corresponding privileges. Different schemas are implemented.
AuthorizationConcept
SQL PrivilegePrivilege SQL statementtype (for example,SELECT, UPDATE, andCALL ...)
Analytic PrivilegeAnalytic Privileges areused to provide row-level authorizationViews.
System PrivilegeUsed for administrativetasks.Sytem Privileges areassigned to users androles.
© 2013 SAP AG. All rights reserved. 3Public
Analytic PrivilegesConcept
Analytic privileges control access to SAP HANA data models.
You can implement row-level security with analytic privileges. However, youcan restrict access in a given data container to selected attribute values,such as:
Field from Attribute viewField from Attribute view used in Analytic viewPrivate dimension of Analytic viewAttribute field in Calculation viewCombinations of the aboveSingle value, range, IN-list
© 2013 SAP AG. All rights reserved. 4Public
Analytic PrivilegesCreation
Define Name and Description
Choose the package
© 2013 SAP AG. All rights reserved. 5Public
Analytic PrivilegesSelect Information Models
Select applicable InformationModels
Views have two functions inAnalytic Privileges– Views to which you want to grant
access
– View from which you want to selectfields for restrictions
You can add further views tothe privilege later
© 2013 SAP AG. All rights reserved. 6Public
Analytic PrivilegesSelect Views
Restrictions apply to all views inlist of “Reference Models”
Choose “Add” in “Reference Models”section– Pick any appropriate view from any
package
Do not use the “Applicable to AllContent Models” option
Reason:– Can have surprising side effects– You give away control over model access
© 2013 SAP AG. All rights reserved. 7Public
Analytic PrivilegesDefine Concrete Restrictions
You may implementvalue restrictions for allselected fields
If no value restrictionimplemented norestrictions (wildcard)Otherwise: user will onlybe allowed to see listedvalues
© 2013 SAP AG. All rights reserved. 8Public
Analytic PrivilegesDynamic Analytic Privileges
Dynamic analytic privileges provide a more flexible approach. The actual filterconditions are obtained at runtime from a stored procedure, which cancontain complex logic.
This enables you to:Reuse the same analytic privilege for several usersChange the filter condition in the underlying tables and views without having to change theanalytic privilege itself
Example:The stored procedure in theanalytic privilege queriesthe user‘s businessdepartment from an orgtable, and checks inanother table whether theuser has manager status.
Attribute Views
Analytic Views
Calculation Views
User3 restrictions
User2 restrictions
User1 restrictionsDynamicAnalyticPrivilege
© 2013 SAP AG. All rights reserved. 9Public
Analytic PrivilegesIn a Role
The last step is toassign the differentprivileges to anauthorization role
© 2013 SAP AG. All rights reserved. Public
© 2013 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation orwarranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Groupproducts and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothingherein should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG inGermany and other countries.Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.
© 2013 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation orwarranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Groupproducts and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothingherein should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG inGermany and other countries.Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.