A Quickstart Guide to Ontopic Studio
Photo by aaron boris on Unsplash
by Ontopic, last update: 26 January 2023 (15 min read)

A Quickstart Guide to Ontopic Studio

Introduction

You have a database and would like to extract key facts and information from it. A virtual knowledge graph (VKG) can be handy for learning new insights from the data in that database. Here, we will use Ontopic Studio, a knowledge graph design software, to create such a virtual knowledge graph in very little time.

Reading Tip: You can find some of the key concepts here.

4 Steps to get you going

  1. Create a new project
  2. Create lenses from the database tables
  3. Map data to classes and properties
  4. Query the knowledge graph

Reading Tip: This is the initial guide to Ontopic Studio. You will find more documentation in the tech notes on this website.



Start using Ontopic Studio

Let’s dive into Ontopic Studio to see how to get insights on data.

We will take a tour of the sample database we are using for this guide, which contains specific information about the hospitality industry in northern Italy.

We are looking for a precise answer, mainly to find information about the names of all the lodging businesses in Bolzano, Italy.

Create a new project

  1. The first step is to create a new project by clicking on the + icon or the text Get started by creating your first project.

    project list

  2. Give your project a name and add a description relevant to the project. Choose Sample DB as project type, so your new project connects to the existing sample database and click on Save.

    diagram of the mapping

    Reading Tip: For this example, selecting Sample DB as the project type is crucial.

After saving, you will automatically land on the dashboard of the newly created project.

Screenshot of Ontopic Studio while mapping a class to data in the relational database

Reading Tip: You can check the connection information about the database under Settings.



List of database tables

Having chosen a Sample DB as project type, the database connection is already set up, and you can see the list of tables by selecting the Lenses tab on the left-side navigation menu

Screenshot of Ontopic Studio while mapping a class to data in the relational database

Reading Tip: Table query actions are accessed from the lenses menu.



What we want to build

Our goal is to build a knowledge graph giving us information about all the lodging businesses in Bolzano.

The following diagram summarizes how we want to connect classes and properties in the knowledge graph to the data in the database tables:

Screenshot of Ontopic Studio while mapping a class to data in the relational database

For our quickstart guide, we will be using the following two tables for the sake of simplicity:

  1. source1.municipalities
  2. source1.hospitality

Reading Tip: The previous image clearly shows how we will construct the knowledge graph from the data.



Creating lenses

The database tables are accessible under the lenses section, which you can access by clicking the item with the same name on the left-side navigation menu. Here we create a lens for a specific table. The lens is a virtual view over the original table, allowing us to visualize and transform the content without altering the data stored in the database. As a general rule, Ontopic Studio does never change any data in the database.

  1. Select Lenses from the left-side navigation menu to get a list of all tables

  2. Select the two tables source1.hospitality and source1.municipalities, by checking the checkboxes and clicking Generate mirror lens on the bottom of the page.

    Screenshot of Ontopic Studio while mapping a class to data in the relational database

Reading Tip: You have further options under the lenses menu from the left-side navigation menu. You can create Mappings only from lenses and not directly from the tables.



Mapping data from the database to a knowledge graph

A mapping connects tables and columns from the database to classes and properties in the knowledge graph. Let’s try them out in this section.


Start populating your Graph (Mapping a lens to a class)

The lens lenses.source1.hospitality contains information about lodging businesses.

The column h_id is the primary key of the underlying table and, therefore, for the lens lenses.source1.hospitality. Thus, each value in h_id identifies a single, specific row in lenses.source1.hospitality. Now, we want to associate each row to an instance of the class voc:LodgingBusiness and construct an identifier for that class instance from h_id.

  1. Select Mapping from the left-side navigation menu, select the lens lenses.source1.hospitality, and then clicking on the c+ icon.

  2. Use the suggested template for generating the identifier for the class instances in our knowledge graph by selecting the first option Create a template and clicking on Create.

    diagram of the mapping

    diagram of the mapping

  3. Then create a new class voc:LodgingBusiness by clicking on Create new class and clicking on Create.

    diagram of the mapping

    diagram of the mapping

  4. Click on Save to obtain the new mapping entry for the class. The resulting mapping entry is as follows:

    diagram of the mapping

Reading Tip: Creating a new class from the mapping section will automatically add the class to the ontology. Likewise, you can also create properties on the fly.



Adding properties to the class instances (Mapping a lens to a data property)

We will use the data from a chosen database table column, in our case, the column with the name of the lodging business, to add properties to the class instances.

We extend our knowledge graph by adding a new property: voc:name to the instances of the class voc:LodgingBusiness we previously mapped.

In our case, we relate the column “name_en” from the lens lenses.source1.hospitality to the data property voc:name.

  1. Create a property by clicking on the P+ icon, which is a new property

    diagram of the mapping

  2. Keeping the template data:source1-hospitality/{h_id} click on Create new property

    diagram of the mapping

  3. We create the property voc:name, and select the type to be data. Click on Create.

    diagram of the mapping

  4. Select name_en as the column from which we read names.

    diagram of the mapping

  5. Click on Save to add the new mapping entry for the property

    The resulting entry is as follows:

    diagram of the mapping

The lens lenses.source1.municipalities contains the data about the municipality, including the identifier and the name. We map this lens to a class and a data property. Therefore, we will create the municipality part of the knowledge graph from this lens, similar to what we did for the lodging businesses:

  1. Add a new class entry voc:Municipality
    1. Select Mapping from the left-side navigation menu, select the lens lenses.source1.municipalities, and then click on the c+ icon.
    2. Use the suggested template for generating the municipality instances in our knowledge graph by selecting the first option Create a template and click on Create.
    3. Then create a new class voc:Municipality by clicking on Create new class.
    4. Click on Save to obtain the new mapping entry for this class.
    5. The resulting entry should be:

      diagram of the mapping

  2. Add a new property entry voc:name to the same subject for name_en
    1. Create a property by clicking on the P+ icon, which adds a new property entry to the same subject.
    2. Keep the template data:source1-municipalities/{m_id} and select voc:name from the property dropdown.
    3. Select name_en as the column name and click on Save.
    4. The resulting entry should be:

      diagram of the mapping

Screenshot of Ontopic Studio while mapping a class to data in the relational database



Connecting lodging businesses to municipalities (Mapping a lens to an object property)

The following mapping entry involves two different identifiers, one about lodging businesses and one about municipalities. We have to connect these two to get the answer to our specific question.

We create an object property for the instances of class voc:LodgingBusiness and instruct Ontopic Studio on how to relate them to the correct instances of the class voc:Municipality.

As a reminder, the column h_id in the lens lenses.source1.hospitality is used for creating the identifier for lodging business, and m_id for the municipalities. We call the property which connects each lodging business to the municipality it belongs to voc:containedIn.

  1. Select Mapping from the left-side navigation menu, select the lens lenses.source1.hospitality, and create a property by clicking on the P+ icon, which is a new property entry.

    Screenshot of Ontopic Studio while mapping a class to data in the relational database

  2. Keeping the same template data:source1-hospitality/{h_id}, create a new property voc:containedIn and select the type to be object. Click on Create.

    diagram of the mapping

    diagram of the mapping

  3. Then select the object kind to be IRI/BNode. Reuse the template data:source1-municipalities/{m_id} for the object.

    diagram of the mapping

  4. Click on Save to add the new property entry. The resulting mapping entry is:

    diagram of the mapping

Screenshot of Ontopic Studio while mapping a class to data in the relational database



Query the knowledge graph

We can now extract key facts by testing the knowledge graph.

Reading Tip: Please check the spelling of class and property names. The results will not populate if there are typos.

  1. Select Query from the left-side navigation menu.

    Screenshot of Ontopic Studio while mapping a class to data in the relational database

  2. Write the query for finding the lodging businesses and click on the play button.
    1. First we query the first 10 lodging businesses by typing:
           PREFIX voc: <http://vocabulary.example.org/>
      
           SELECT * WHERE {
               ?sub a voc:LodgingBusiness;
               voc:name ?name.
           } LIMIT 10
      
      
    2. We can filter the result for those businesses which are in Bolzano:
           PREFIX voc: <http://vocabulary.example.org/>
      
           SELECT * WHERE {
               ?sub a voc:LodgingBusiness;
               voc:name ?name;
               voc:containedIn ?place.
               ?place voc:name "Bolzano/Bozen" .
           } LIMIT 10
      
  3. The response from the virtual knowledge graph is:
    1. The first 10 lodging businesses

      diagram of the mapping

    2. The first 10 located in Bolzano

      diagram of the mapping

Reading Tip: The query history is shown on the right side. You can run the query in the history by selecting it and clicking on the play button.


Conclusion

Thank you for using Ontopic Studio. We are sure you will encounter more complex use cases, so please let us know if you want more explanations or a more extended manual, by simply sending us an email at: support@ontopic.ai.

If you would like more explanations from one of our specialists, please book a free consultation here.

For sales inquiries, please email us at: a@b.c

Get a demo access of Ontopic Studio

Ready to do mapping with a no-code approach? Let us help you. Get a demo access:


We'll never share your email with anyone else.
Please supply a valid email address

From time to time we send updates.