2

I want to build a knowledge graph for specific story-line, so for that I have extracted Relationship triplets (S,P,O) using OpenIE. Now I am want to create graph database from these Relationship triplets which I don't know how to do. So here is my questions:
1) Which graph database should I use and why ?
2) How do I create Database from relationship triplets or Is it possible to create a relationship graph in any graph database from raw relationship triplets?

For example suppose I select Neo4j as Graph Database:
Relationship triplets looks like : ['Barack Obama', ' was born in', ' Hawaii']
How do I create the Neo4j graph pro-grammatically from ['Barack Obama', ' was born in', ' Hawaii'] ?

Barak Obama and Hawaii are Nodes.
was born in is Relationship

Rishi Kesh
  • 71
  • 5

1 Answers1

2

Using OrientDB you can do that in this way:

create class Person extends V
create property Person.name string
create property Person.surname string
insert into Person(name, surname) values ("Barack","Obama")

create class Country extends V
create property Country.name string
insert into Country(name) values ("Hawaii")

create class was_born_in extends E

create edge was_born_in from (select from Person where name = "Barack") to (select from Country where name = "Hawaii")

This is the situation:

+----+-----+-------+------+-------+---------------+--------------+
|#   |@RID |@CLASS |name  |surname|out_was_born_in|in_was_born_in|
+----+-----+-------+------+-------+---------------+--------------+
|0   |#17:0|Person |Barack|Obama  |[#25:0]        |              |
|1   |#21:0|Country|Hawaii|       |               |[#25:0]       |
+----+-----+-------+------+-------+---------------+--------------+

If you run this query:

select expand(in('was_born_in')) from Country where name = "Hawaii"

You'll get all the people living in the Hawaii

+----+-----+------+------+-------+---------------+
|#   |@RID |@CLASS|name  |surname|out_was_born_in|
+----+-----+------+------+-------+---------------+
|0   |#17:0|Person|Barack|Obama  |[#25:0]        |
+----+-----+------+------+-------+---------------+

Hope it helps

Regards

Michela Bonizzi
  • 2,622
  • 1
  • 9
  • 16