Creating an Entity in a Graph Database
Â
Since version 3.1.0-KickOff, Ontologies have been referred to as "Entities" in the Control Panel. This does not alter any functionality; the nomenclature has simply been changed for a better understanding of the concept.
Available since version 4.2.0-Predator.
User Interface: 5.3.2-Ultimate
Introduction
In this article we are going to explain how to work with stored entities on Nebula Graph, for the cases in which you want to work with graph-based storage technologies.
Steps
Create the Entity
From the Control Panel, navigate to the Development > My Entities menu.
This will take us to the list of available Entities. To create the Entity, click on the "+" button at the top right of the screen.
From the different Entities that we will be able to create, we will select the "Creation Entity in Graph Database" one:
Fill in general information
In the first tab we will fill in the basic data about the entity, which will represent a space in Nebula Graph, that is, it will contain the definition of the vertices and edges. We will have to choose the number of partitions and replicas for the entity (space) that we are going to create, by default 15 and 1 respectively.
In the next tab we will define the vertices and edges, as we add properties of both they will appear in the associated table.
Then click on the create button.
If we access the 'view entity' icon (eye) we will be able to see the definition of vertices and edges.
Entering data
Once the entity is created, we can execute all types of nGQL queries from query tool.
For this example we will create the following data:
#VERTICES
INSERT VERTEX player(name, age) VALUES "player100":("Tim Duncan", 42);
INSERT VERTEX player(name, age) VALUES "player101":("Tony Parker", 36);
INSERT VERTEX player(name, age) VALUES "player102":("LaMarcus Aldridge", 33);
INSERT VERTEX player(name, age) VALUES "player103":("Michael Jordan", 52);
INSERT VERTEX team(name) VALUES "team203":("Trail Blazers"), "team204":("Spurs");
#ARISTAS
INSERT EDGE follow(degree) VALUES "player101" -> "player100":(95);
INSERT EDGE follow(degree) VALUES "player101" -> "player102":(90);
INSERT EDGE follow(degree) VALUES "player101" -> "player103":(70);
INSERT EDGE follow(degree) VALUES "player102" -> "player100":(75);
INSERT EDGE follow(degree) VALUES "player102" -> "player100":(75);
INSERT EDGE follow(degree) VALUES "player103" -> "player101":(55);
INSERT EDGE serve(start_year, end_year) VALUES "player101" -> "team204":(1999, 2018),"player102" -> "team203":(2006, 2015),"player103" -> "team203":(1990, 2022);
With this we will now have data to perform queries.
Queries
As we have said before, we can make any type of query in nGQL format, let's see some examples:
FETCH PROP ON player "player100" YIELD properties(vertex) as player_properties;
GO FROM "player101" OVER follow YIELD id($$) as vid;
Apification
We can also apify the entity to perform queries via HTTP.
When we select a network type entity to qualify, only one operation will be available.
Nebula Graph UI
From the entity list, when an entity is stored in Nebula Graph, you will have an option to access the Nebula UI.
When accessing, a new tab will open, where we will have to enter the following data of acceso:
And select the entity/space in the combo box:
Then we will access the Explorer to be able to visualize the graph of our data within the entity.
To visualize a complete initial network, we can select the button 'Start with vertices', and then 'Import Sample'.
Â
Â
Â