# Quickstart
# Introduction
In this tutorial we will learn how to use Ontopic Studio a powerful Knowledge Graph design software, to extract key facts and insights from your database.
# 4 Steps to get you going
- Create a new project
- Create lenses from the database tables
- Map data to classes and properties
- Query the Knowledge Graph
# Create a new project
The first step is to create a new project by clicking on the + icon or the text Get started by creating your first project.
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.
After saving, you will automatically land on the dashboard of the newly created project.
# 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
# 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:
For our tutorial, we will be using the following two tables for the sake of simplicity:
- source1.municipalities
- source1.hospitality
# Creating lenses
Select Lenses from the left-side navigation menu to get a list of all tables
Select the two tables source1.hospitality and source1.municipalities, by checking the checkboxes and clicking Generate mirror lens on the bottom of the page.
Note: If you are using the Windows Desktop version select DESTINATION-DB.source1.hospitality and DESTINATION-DB.source1.municipalities .
# Mapping data from the database to a Knowledge Graph
# Start populating your Graph (Mapping a lens to a class)
Select Mapping from the left-side navigation menu, select the lens lenses.source1.hospitality, and then clicking on the c+ icon.
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.
Then create a new class voc:LodgingBusiness by clicking on Create new class and clicking on Create.
Click on Save to obtain the new mapping entry for the class. The resulting mapping entry is as follows:
# Adding properties to the class instances (Mapping a lens to a data property)
Create a property by clicking on the P+ icon, which is a new property
Keeping the template data:source1-hospitality/{h_id} click on Create new property
We create the property voc:name, and select the type to be data. Click on Create.
Select name_en as the column from which we read names.
Click on Save to add the new mapping entry for the property
The resulting entry is as follows:
Add a new class entry voc:Municipality
Select Mapping from the left-side navigation menu, select the lens lenses.source1.municipalities, and then click on the c+ icon.
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.
Then create a new class voc:Municipality by clicking on Create new class.
Click on Save to obtain the new mapping entry for this class.
The resulting entry should be:
Add a new property entry voc:name to the same subject for name_en
Create a property by clicking on the P+ icon, which adds a new property entry to the same subject.
Keep the template data:source1-municipalities/{m_id} and select voc:name from the property dropdown.
Select name_en as the column name and click on Save.
The resulting entry should be:
# Connecting lodging businesses to municipalities (Mapping a lens to an object property)
The following mapping entry (opens new window) 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.
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.
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.
Then select the object kind to be IRI/BNode (opens new window). Reuse the template data:source1-municipalities/{m_id} for the object.
Click on Save to add the new property entry. The resulting mapping entry is:
# Query the Knowledge Graph
We can now extract key facts by testing the Knowledge Graph.
Select Query from the left-side navigation menu.
Write the query for finding the lodging businesses and click on the play button.
- 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
The first 10 lodging businesses
- 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
The first 10 located in Bolzano
- First we query the first 10 lodging businesses by typing:
# Materialize data into a graph database
Materialize in RDF files and load into a triplestore (starting from 2024.1).
Materialization to RDF is disabled by default (except for the Desktop version, where files are stored locally). See how to enable materialization with S3.
Click on Materialize to materialize the knowledge graph into an RDF file.
Then select the RDF format
Then select the Compression format
You can materialize your KG into one file in compress or uncompress format. For simplicity, we keep the default option and materialize with zip compression.
Click on Materialize, you will have all the content of KG copied to the file materialized-triples.ttl.
Now you can load this file in the triplestore of your choice, in this case, use GraphDB (opens new window). This graph database offers several ways to load files (opens new window). Here, since the file is only 200 MB, we go for the simplest option and load it directly from the UI.
We can now see the list of materialized files by clicking on List files.
This will show a list of all materialized files. Each materialized file has three associated actions: "Export materialized file" or "Open directory", "Copy file location to clipboard", and "Delete materialized file".