- Insert Instances of an Entity Type
- Insert Instances of an Attribute Type
- Insert Instances of a Relation Type
- Clients Guide
Insert Instances of an Entity Type
To insert an instance of an entity type into the knowledge graph, we use the
insert keyword followed by a series of statements that are similar to match patterns. To try the following examples with one of the Grakn clients, follows these Clients Guide.
insert query inserts a
person with a
full-name attribute of
John Parkson, an
firstname.lastname@example.org and a phone number of
Insert Instances of an Attribute Type
Similar to inserting an instance of an entity, to insert an instance of an attribute, we use the
insert keyword followed by the variable pattern to describe the attribute of interest and its value.
Insert Instances of a Relation Type
Given the dependent nature of relations, inserting an instance of a relation is quite different from that of an entity. The roles of a relation to be inserted are expected to be played by instances that already exist in the knowledge graph. Therefore inserting a relation is always preceded by matching the roleplayers - what is commonly called the
match insert. What follows the
insert keyword, is a series of statements that are similar to the match patterns.
match insert query:
- Matches the
employer, assigned to variable
- Matches the
employee, assigned to variable
- Inserts an
$personas its roleplayers, assigned to variable
- Inserts the ownership of
insert query optionally preceded by a
match clause is used to insert a data instance into the knowledge graph.
Next, we learn how to delete data from a knowledge graph.