Vous êtes sur la page 1sur 75

Week 2 Unit 1: Database Schemas and Database Tables

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

2013 SAP AG. All rights reserved.

Public

Database Schemas and Database Tables The SAP HANA Repository


Manage all artifacts in one repository Presentation (UI) Control flow (Application) Data persistence:
Tables Views Schemas

Client Presentation logic


Presentation artifacts

HANA Control flow logic


Control flow artifacts

Calculation logic Data


Data artifacts

2013 SAP AG. All rights reserved.

Public

Database Schemas and Database Tables


Data Persistence in SAP HANA

Data persistence objects Schemas Tables SQL views Sequences Procedures

2013 SAP AG. All rights reserved.

Public

Database Schemas and Database Tables


Database Schemas for SAP HANA

Database object Mandatory Contains logical groups:


Tables Views Procedures Sequences

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Database Schemas and Database Tables


Design-time Schemas: Configuration Syntax (.hdbschema)

Mandatory syntax (.hdbschema) Schema name keyword Schema name Authorizations

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

10

Week 2 Unit 2: Sequences and SQL Views

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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)

2013 SAP AG. All rights reserved.

Public

Sequences and SQL Views


SQL Views for SAP HANA

Database object
<package.path>::<ViewName>

SQL statements/queries Join data from different tables

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Week 2 Unit 3: Authorizations

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

2013 SAP AG. All rights reserved.

Public

Authorizations
Building Repository Roles: Create

Design-time object Transportable Plain text file Mandatory file suffix (.hdbrole) Repository activation creates runtime object in the catalog

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Week 2 Unit 4: EPM Demo Schema

EPM Demo Schema


Available EPM Demo Data

The EPM demo data includes the following catalog objects: Tables Views Sequences Synonyms

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Week 2 Unit 5: Single File Data Load of CSVs

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)

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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)

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Week 2 Unit 6: Attribute Views

Attribute Views
Overview

Attribute views:
Model an entity based upon relationships of multiple source tables

Can contain:
Columns Calculated columns Hierarchies

2013 SAP AG. All rights reserved.

Public

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.

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Attribute Views
Defining Field and Column Properties

The properties of a view column affect the overall usage:


Key Attribute Drilldown-Enabled Hidden

2013 SAP AG. All rights reserved.

Public

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)

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Attribute Views
Data Preview

Preview the data displayed by the view

2013 SAP AG. All rights reserved.

Public

Attribute Views
Data Preview with Analysis

2013 SAP AG. All rights reserved.

Public

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.

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.

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.

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.

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.

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.

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.

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.

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

Calculation Views
Two Types

View or Table Analytic View Join

2013 SAP AG. All rights reserved.

Public

Calculation Views
View Creation Wizard

Assign a unique name must be alphanumeric (A-Z; 0-9; _) Select Graphic or SQLScript

2013 SAP AG. All rights reserved.

Public

Calculation Views
Selecting Components

Select any tables, attribute views, or analytic views to add to the Calculation view.

2013 SAP AG. All rights reserved.

Public

Calculation Views
Selecting Components

You can add projection nodes to add extra fields. For example, adding the currency converted amount field

2013 SAP AG. All rights reserved.

Public

Calculation Views
Output Definition

Choose the fields that should be available for the next level

2013 SAP AG. All rights reserved.

Public

Calculation Views
Calculated Column

2013 SAP AG. All rights reserved.

Public

Calculation Views
Define Union

2013 SAP AG. All rights reserved.

Public

Calculation Views
Scripted Views Overview

Traditional: Data to Code Application Layer

New Model: Code to Data Application Layer

Code
Massive data copies create bottleneck

Transfer minimum result set

DB Layer

DB Layer

Code

2013 SAP AG. All rights reserved.

Public

Calculation Views
Define Output Structure, Define Function and SQLScript

2013 SAP AG. All rights reserved.

Public

10

Calculation Views
Define Which Columns are Attributes or Measures

You need to select the attributes and measures for the output node.

2013 SAP AG. All rights reserved.

Public

11

Week 2 Unit 9: Analytic Privileges

Analytic Privileges
Types of Privileges

SQL Privilege
Privilege SQL statement type (for example, SELECT, UPDATE, and CALL ...)

System Privilege SQL privilege SYSTEM privilege


Used for administrative tasks. Sytem Privileges are assigned to users and roles.

Authorization Concept

Analytic Privilege
Analytic Privileges are used to provide rowlevel authorization Views.

Package privilege

Analytic privilege

When you access the SAP HANA database, ensure that any access to data is backed by corresponding privileges. Different schemas are implemented.

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

Analytic Privileges
Creation

Define Name and Description Choose the package

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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

2013 SAP AG. All rights reserved.

Public

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 users business department from an org table, and checks in another table whether the user has manager status.
User3 restrictions User2 restrictions Dynamic Analytic Privilege User1 restrictions Attribute Views Analytic Views Calculation Views

2013 SAP AG. All rights reserved.

Public

Analytic Privileges
In a Role

The last step is to assign the different privileges to an authorization role

2013 SAP AG. All rights reserved.

Public

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

Vous aimerez peut-être aussi