SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Try Out Multi-Model Functionality with the SAP HANA Database Explorer and Database Objects App

Explore knowledge graph, property graph, JSON document store, and spatial capabilities in the SAP HANA database explorer.

Overview

🎓 beginner 15 min. SAP HANA CloudBeginnerSAP HANA Cloud SAP HANA DatabaseSAP HANASAP HANA Express EditionSAP HANA Multi Model ProcessingSAP HANA SpatialSAP HANA Graph

You will learn

  • โœ”How to create a knowledge graph, a property graph, a document store, and import spatial data.
  • โœ”How the SAP HANA database explorer and the database objects app can be used with multi-model data.

Prerequisites

Prerequisites

  • A productive SAP HANA Cloud database
  • You have completed the first 3 tutorials in this group.

Steps

Intro

A knowledge graph can be used to store facts in triples providing additional meaning and relationships.

A property graph can be used to show the connections between items such as the connections between airports or between people or groups in a social network.

SAP HANA Cloud provides the ability to store and perform queries on spatial data such as a point, a line segment, or a polygon. Additional details can be found at SAP HANA Cloud, SAP HANA Database Spatial Reference.

This tutorial is meant to be an introduction to this topic. For additional content see the tutorial groups Introduction to SAP HANA Spatial Data Types, Smart Multi-Model Data Processing with SAP HANA Cloud, and the multi-model chapters in Basic Trial - Introduction to SAP HANA Cloud that is available once you sign up for the basic trial.


Step 1 Enable the triple store and Create a knowledge graph
โ€”

The following steps will create a knowledge graph that provides information on additional hotel amenities, explore the created knowledge graph using the database objects app, and then will perform a query on the knowledge graph.

Before you can create a knowledge graph, please ensure your HANA Instance is version 2025.2 or above, and your instance has triple store activated. Here are the steps to doing this:

  1. Go to Manage Configuration on your SAP HANA Cloud Database.

    Manage Configuration
    Manage Configuration

  2. Under the General Tab, change the version of your instance to 2025.2 or above

    Change Instance Version
    Change Instance Version

  3. Under the Advanced Settings Tab, check off the Triple Store option if it’s not already on.

    Add Triple Store
    Add Triple Store

    The knowledge graph feature is not available for free tier instances.

    To learn more about knowledge graphs see Connecting the Facts: SAP HANA Cloudโ€™s Knowledge Graph Engine for Business Context and Choosing Between Knowledge Graphs and Property Graphs in SAP HANA Cloud and Why Both Matter.

  4. Execute the following in the SQL Console. This query creates a KG with several hotels and amenities such as an indoor pool, hot tub, fitness center, etc.

    SQL
    --CALL SPARQL_EXECUTE('DROP GRAPH <kg_hotels>', '', ?, ?);
    CALL SPARQL_EXECUTE('
        INSERT DATA { GRAPH <kg_hotels> { 
            <http://example.org/hotels/Delta> a <Hotel>;
            <name> "Delta";
            <city> "Waterloo";
            <yearBuilt> 2012 .
    
            <http://example.org/hotels/hotelamenities/IndoorPool1> a <IndoorPool>;
            <included_at> <http://example.org/hotels/Delta>;
            <length> 25;
            <width> 10.
    
            <http://example.org/hotels/hotelamenities/Hottub1> a <Hottub>;
            <included_at> <http://example.org/hotels/Delta>;
            <length> 6;
            <width> 6.
    
            <http://example.org/hotels/hotelamenities/FitnessCenter1> a <FitnessCenter>;
            <included_at> <http://example.org/hotels/Delta>.
    
            <http://example.org/hotels/hotelamenities/Keurig> a <CoffeeMaker>;
            <included_at> <http://example.org/hotels/Delta>. 
    
            <http://example.org/hotels/Sunshine> a <Hotel>;
            <name> "Sunshine";
            <city> "Clearwater";
            <yearBuilt> 1975 .
    
            <http://example.org/hotels/hotelamenities/Restaurant1> a <Restaurant>;
            <included_at> <http://example.org/hotels/Sunshine>;
            <seating> 95.
    
            <http://example.org/hotels/hotelamenities/FitnessCenter2> a <FitnessCenter>;
            <included_at> <http://example.org/hotels/Sunshine>.
    
            <http://example.org/hotels/hotelamenities/Laundry1> a <DryCleaning>;
            <included_at> <http://example.org/hotels/Sunshine>. 
    
            <http://example.org/hotels/Congress> a <Hotel>;
            <name> "Congress";
            <city> "Seattle";
            <yearBuilt> 2012 .
    
            <http://example.org/hotels/hotelamenities/IndoorPool2> a <IndoorPool>;
            <included_at> <http://example.org/hotels/Congress>;
            <length> 30;
            <width> 15.
    
            <http://example.org/hotels/hotelamenities/Restaurant2> a <Restaurant>;
            <included_at> <http://example.org/hotels/Congress>;
            <seating> 122.
    
            <http://example.org/hotels/hotelamenities/FitnessCenter3> a <FitnessCenter>;
            <included_at> <http://example.org/hotels/Congress>.
    
            <http://example.org/hotels/hotelamenities/Spa1> a <Spa>;
            <included_at> <http://example.org/hotels/Congress>. 
    
            <http://example.org/hotels/OceanStar> a <Hotel>;
            <name> "Ocean Star";
            <city> "Atlantic City";
            <yearBuilt> 2012 .
    
            <http://example.org/hotels/hotelamenities/IndoorPool3> a <IndoorPool>;
            <included_at> <http://example.org/hotels/OceanStar>;
            <length> 50;
            <width> 30.
    
            <http://example.org/hotels/hotelamenities/Restaurant2> a <Restaurant>;
            <included_at> <http://example.org/hotels/OceanStar>;
            <seating> 205.
    
            <http://example.org/hotels/hotelamenities/Cleaning1> a <CleaningServices>;
            <included_at> <http://example.org/hotels/OceanStar>.
    
            <http://example.org/hotels/hotelamenities/Spa2> a <Spa>;
            <included_at> <http://example.org/hotels/OceanStar>. 
    
            <http://example.org/hotels/LongIsland> a <Hotel>;
            <name> "LongIsland";
            <city> "Long Island";
            <yearBuilt> 2021 .
    
            <http://example.org/hotels/hotelamenities/Entertainment1> a <Entertainment>;
            <included_at> <http://example.org/hotels/LongIsland>.
    
            <http://example.org/hotels/hotelamenities/Restaurant3> a <Restaurant>;
            <included_at> <http://example.org/hotels/LongIsland>;
            <seating> 122.
    
            <http://example.org/hotels/hotelamenities/Cleaning2> a <CleaningServices>;
            <included_at> <http://example.org/hotels/LongIsland>.
    
            <http://example.org/hotels/hotelamenities/Spa3> a <Spa>;
            <included_at> <http://example.org/hotels/LongIsland>. 
    
            <http://example.org/hotels/hotelamenities/Hottub2> a <Hottub>;
            <included_at> <http://example.org/hotels/LongIsland>. 
        } 
        }
        ', '', ?, ?
    );

    Additional examples can be found at SAP HANA Cloud, SAP HANA Database SPARQL Reference Guide

  5. To visualize and examine the knowledge graph database objects, you must first enable the feature in your preferences. Click on your account

    Account Settings
    Account Settings

    Go to the Database Objects tab

    Database Objects Tab
    Database Objects Tab

    Enable RDF Named Graphs

    Enable RDF Graphs
    Enable RDF Graphs

    You will now have the RDF Named Graphs view available. Click on it to view the graphs you have created

    RDF Named Graphs View
    RDF Named Graphs View

    The DEFAULT graph is where content goes when it doesn’t have a name. For more information, review the DEFAULT_GRAPHS and Named Graphs help page.

    Click on the kg_hotels graph, and open the graph ontology to see the nodes.

    Graph Ontology View
    Graph Ontology View

  6. Run a query to find hotelsย that have an indoor pool.

    SQL
    SELECT *
    FROM SPARQL_TABLE('
    PREFIX ex: <http://example.org/hotels/>
    SELECT ?hotel ?hotelName ?city ?yearBuilt ?poolLength ?poolWidth
    FROM <kg_hotels>
    WHERE {
        ?hotel a <Hotel> ;
    <name> ?hotelName ;
    <city> ?city ;
    <yearBuilt> ?yearBuilt .
        ?pool a <IndoorPool> ;
    <included_at> ?hotel ;
    <length> ?poolLength ;
    <width> ?poolWidth .
    }
    ');

    Further examples of creating SPARQL statements can be found at SPARQL SELECT Queries Using SPARQL_TABLE.

Step 2 Create a property graph workspace
+
Step 3 Explore a property graph using the viewer
+
Step 4 Use property graph algorithms in the SAP HANA database explorer
+
Step 5 Create, populate, and query a JSON collection (optional)
+
Step 6 Import a JSON collection using the hana_ml.docstore package (optional)
+
Step 7 Import and view spatial data
+
Step 8 Use spatial functions in a query
+
Step 9 Knowledge check
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 9
1. Enable the triple store and Create a knowledge graph 2. Create a property graph workspace 3. Explore a property graph using the viewer 4. Use property graph algorithms in the SAP HANA database explorer 5. Create, populate, and query a JSON collection (optional) 6. Import a JSON collection using the hana_ml.docstore package (optional) 7. Import and view spatial data 8. Use spatial functions in a query 9. Knowledge check

Learn more →