Week 2 Unit 1: Database Schemas and Database Tables
2 Database Schemas and Database Tables The SAP HANA Repository Object management, versioning, and transport Software component delivery and patching Built-in support for translatable texts Support for server-based development
3 Database Schemas and Database Tables The SAP HANA Repository Manage all artifacts in one repository Presentation (UI) Client Presentation logic Presentation artifacts Control flow (Application) Data persistence: Tables Views Schemas HANA Control flow logic Control flow artifacts Calculation logic Data Data artifacts
4 Database Schemas and Database Tables Data Persistence in SAP HANA Data persistence objects Schemas Tables SQL views Sequences Procedures
5 Database Schemas and Database Tables Database Schemas for SAP HANA Database object Mandatory Contains logical groups: Tables Views Procedures Sequences
6 Database Schemas and Database Tables Design-time Schemas for SAP HANA Design-time object Transportable Plain text file Mandatory file suffix (.hdbschema) Repository activation creates runtime object in the catalog
7 Database Schemas and Database Tables Design-time Schemas: Configuration Syntax (.hdbschema) Mandatory syntax (.hdbschema) Schema name keyword Schema name Authorizations
8 Database Schemas and Database Tables Database Tables for SAP HANA Database object <package.path>::<tablename> A set of data elements Type: Column Row Metadata: Constraints on table Constraints on values in particular columns
9 Database Schemas and Database Tables Design-time Tables for SAP HANA Design-time object Transportable Plain text file Mandatory file suffix (.hdbtable) Repository activation creates runtime object in the catalog
10 Database Schemas and Database Tables Design-time Tables: Configuration Syntax (.hdbtable) Mandatory syntax (.hdbtable) Schema name Table type Column/Row Table columns Name, SQL type, length Data types NVARCHAR, DATE, DECIMAL Primary key
Week 2 Unit 2: Sequences and SQL Views
2 Sequences and SQL Views Database Sequences for SAP HANA Database object <package.path>::<sequencename> Generates an incremented list of numeric values Ascending/descending order Used by applications to: Reference sequence objects Generate primary key values Identify table columns/rows Coordinate keys across rows/tables
3 Sequences and SQL Views Design-Time Sequences for SAP HANA Design-time object Transportable Plain text file Mandatory file suffix (.hdbsequence) Repository activation creates runtime object in the catalog
4 Sequences and SQL Views Design-Time Sequences: Configuration Syntax (.hdbsequence) Mandatory syntax.hdbsequence Keywords: schema start_with nomaxvalue nominvalue cycles depends_on_table depends_on_view Usage: SQL Insert (NEXTVAL)
5 Sequences and SQL Views SQL Views for SAP HANA Database object <package.path>::<viewname> SQL statements/queries Join data from different tables
6 Sequences and SQL Views Design-Time SQL Views for SAP HANA Design-time object Transportable Plain text file Mandatory file suffix (.hdbview) Repository activation creates runtime object in the catalog
7 Sequences and SQL Views Design-Time SQL Views: Configuration Syntax (.hdbview) Mandatory syntax Schema name SQL query: JSON notation (\ Name\ ) Select from left outer join on order by depends_on_table/view Joined table names: <package.path>::header <package.path>::item
Week 2 Unit 3: Authorizations
2 Authorizations Available Active Roles: Overview Default Roles: CONTENT_ADMIN MODELING PUBLIC Imported Roles: <PackagePath>::<RoleName> sap.hana.xs.admin::administrator sap.hana.xs.admin::viewer sap.hana.ui5.db::site_designer sap.hana.ui5.db::site_user
3 Authorizations Building Repository Roles: Create Design-time object Transportable Plain text file Mandatory file suffix (.hdbrole) Repository activation creates runtime object in the catalog
4 Authorizations Building Repository Roles: Define Role name Extends another role Privileges: Schema SELECT, INSERT, UPDATE, DELETE, DROP Application: ADMIN (EXECUTE, SAVE ) System SQL objects Packages Analytic Commit/Activate
5 Authorizations Building 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
2 EPM Demo Schema Available EPM Demo Data The EPM demo data includes the following catalog objects: Tables Views Sequences Synonyms
3 EPM Demo Schema EPM Demo Data: Tables A table is a set of data elements that are organized using columns and rows. EPM Tables: Addresses Business partners Employees Products Sales orders
4 EPM Demo Schema EPM Demo Data: Views A view is a virtual table based on the dynamic results returned in response to an SQL statement. EPM Views PurchaseOrderHeaderExt
5 EPM Demo Schema EPM Demo Data: Sequences A sequence is a database object that generates an automatically incremented list of numeric values to identify tables, columns, or rows. EPM Sequences: Address ID Employee ID Partner ID Purchase Order ID Sales Order ID Text ID
6 EPM Demo Schema EPM Demo Data: Synonyms A synonym is an alternative name for a database table. EPM Synonyms: TCURC TCURF TCURN TCURR TCURT TCURV TCURW
Week 2 Unit 5: Single File Data Load of CSVs
2 Single File Data Load of CSVs Automatic Table Data Load: Required Files CSV file Holds data, separated by commas, to load into target table Table Import Model Defines target DB table for load Mandatory file suffix (.hdbtim) Table Import Data Connects CSV file to data load model file (.hdbtim ) Mandatory file suffix (.hdbtid)
3 Single File Data Load of CSVs Automatic Table Data Load: Source File Data source file Transportable, design-time object Contains the values to load into the database table Values separated by commas Number of columns in CSV file/ target table must match Data types in target table/csv columns must match
4 Single File Data Load of CSVs Automatic 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 in the database ( item )
5 Single File Data Load of CSVs Automatic Table Data Load: Import Data Table import data file Design-time object Transportable Mandatory file suffix (.hdbtid) Connects the CSV source file to the data load model file Specifies the source CSV file
6 Single File Data Load of CSVs Automatic Table Data Load: SQL Query to View Results SELECT TOP 1000 * FROM Schema name WORKSHOPX_00 Namespace workshop.sessionx.00.data Object delimiter double colon (::) Table name item
Week 2 Unit 6: Attribute Views
2 Attribute Views Overview Attribute views: Model an entity based upon relationships of multiple source tables Can contain: Columns Calculated columns Hierarchies
3 Attribute Views Defining Sources and Relationships Define an attribute view: Sources The main components of an attribute view are tables. Relationships Join fields in tables to get a consistent definition of the overall entity.
4 Attribute Views Defining the Output Structure Example: Tables often contain a large number of columns. Add only the columns you really need in the output structure. Field selection Output structure
5 Attribute Views Defining Field and Column Properties The properties of a view column affect the overall usage: Key Attribute Drilldown-Enabled Hidden
6 Attribute Views Defining Calculated Output Fields 1 To define a new calculated output field that is based on existing fields in the view, you can use: Other output fields Formulas Conversion (unit of measure and currency)
7 Attribute Views Defining Calculated Output Fields 2 To define a new calculated output field, you must specify: The data type The field width The scale The rule definition
8 Attribute Views Data Preview Preview the data displayed by the view
Attribute Views Data Preview with Analysis 2013 SAP AG. All rights reserved. Public 9
Week 2 Unit 7: Analytic Views
Analytic Views Overview Analytic Views: Leverage the computing power of SAP HANA to calculate aggregate data Contain two types of columns Attributes Measures 2013 SAP AG. All rights reserved. 2
Analytic Views Set Parameters Assign a unique name for the technical name of the analytic view Change the view type to Analytic View 2013 SAP AG. All rights reserved. 3
Analytic Views Definition of Data Foundation and Logical Joins Explanation of terms: Data Foundation: Represents the tables used for defining the fact table of the view Logical Join: Represents the relationship between the selected table fields (fact table) and attribute views 2013 SAP AG. All rights reserved. 4
Analytic Views Data Foundation View The Data Foundation view shows all the fields that can be incorporated into the final model. These fields are marked as output fields 2013 SAP AG. All rights reserved. 5
Analytic Views Logical Join The Logical Join view displays only those fields you have chosen to include in this model, as well as the restricted and calculated measures that have been defined. 2013 SAP AG. All rights reserved. 6
Analytic Views Semantics View In the Semantics view, you can classify the columns and calculated columns as attributes and measures. You can also create variables/input parameters and hierarchies and assign variables to the columns. 2013 SAP AG. All rights reserved. 7
Analytic Views Calculated Columns There are many options for defining a calculated measure: Aggregation, such as sum, minimum, maximum, and count Data types, such as decimals, numbers, and so on Expressions or operators String, date math, conversion, and so on 2013 SAP AG. All rights reserved. 8
Analytic Views Restricted Columns The restriction for a measure is based on an attribute value. In the example, the measure RC_PRODUCT_CAT_NOTEBOOKS shows only Gross Amount values from the Product Category Notebooks. 2013 SAP AG. All rights reserved. 9
Analytic Views Data Preview The same options exist here as exist for the attributes view: Raw data Distinct values Analysis 2013 SAP AG. All rights reserved. 10
Week 2 Unit 8: Calculation Views
2 Calculation Views Two Types View or Table Analytic View Join
3 Calculation Views View Creation Wizard Assign a unique name must be alphanumeric (A-Z; 0-9; _) Select Graphic or SQLScript
4 Calculation Views Selecting Components Select any tables, attributes, or analytic views to add to the Calculation view.
5 Calculation Views Selecting Components You can add projection nodes to add extra fields. For example, adding the currency converted amount field
6 Calculation Views Output Definition Choose the fields that should be available for the next level
Calculation Views Calculated Column 2013 SAP AG. All rights reserved. Public 7
Calculation Views Define Union 2013 SAP AG. All rights reserved. Public 8
9 Calculation Views Scripted Views Overview Traditional: Data to Code New Model: Code to Data Massive data copies create bottleneck Application Layer Code Transfer minimum result set Application Layer DB Layer DB Layer Code
Calculation Views Define Output Structure, Define Function and SQLScript 2013 SAP AG. All rights reserved. Public 10
11 Calculation Views Define Which Columns are Attributes or Measures You need to select the attributes and measures for the output node.
Week 2 Unit 9: Analytic Privileges
2 Analytic Privileges Types of Privileges SQL Privilege System Privilege Privilege SQL statement type (for example, SELECT, UPDATE, and CALL...) SQL privilege Authorization Concept SYSTEM privilege Used for administrative tasks. Sytem Privileges are assigned to users and roles. Analytic Privilege Package privilege Analytic privilege Analytic Privileges are used to provide rowlevel authorization Views. When you access the SAP HANA database, ensure that any access to data is backed by corresponding privileges. Different schemas are implemented.
3 Analytic Privileges Concept Analytic privileges control access to SAP HANA data models. You can implement row-level security with analytic privileges. However, you can restrict access in a given data container to selected attribute values, such as: Field from Attribute view Field from Attribute view used in Analytic view Private dimension of Analytic view Attribute field in Calculation view Combinations of the above Single value, range, IN-list
4 Analytic Privileges Creation Define Name and Description Choose the package
5 Analytic Privileges Select Information Models Select applicable Information Models Views have two functions in Analytic Privileges Views to which you want to grant access View from which you want to select fields for restrictions You can add further views to the privilege later
6 Analytic Privileges Select Views Restrictions apply to all views in list of Reference Models Choose Add in Reference Models section Pick any appropriate view from any package Do not use the Applicable to All Content Models option Reason: Can have surprising side effects You give away control over model access
7 Analytic Privileges Define Concrete Restrictions You may implement value restrictions for all selected fields If no value restriction implemented no restrictions (wildcard) Otherwise: user will only be allowed to see listed values
8 Analytic Privileges Dynamic Analytic Privileges Dynamic analytic privileges provide a more flexible approach. The actual filter conditions are obtained at runtime from a stored procedure, which can contain complex logic. This enables you to: Reuse the same analytic privilege for several users Change the filter condition in the underlying tables and views without having to change the analytic privilege itself Example: The stored procedure in the analytic privilege queries the user s business department from an org table, and checks in another table whether the user has manager status. Dynamic Analytic Privilege User3 restrictions User2 restrictions User1 restrictions Attribute Views Analytic Views Calculation Views
9 Analytic Privileges In a Role The last step is to assign the different privileges to an authorization role
Thank you Contact information: open@sap.com
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 or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein 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 in Germany 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. Public