How to use label inheritance in AgensGraph?

AgensGraph can support inheritance between labels like OOP (Object oriented Programming). ‘Label Inherits ‘ help to make decreasing entities to modeling when modeling real-world to graph-model. But that don’t mean that child label inherits properties of parent. (AgensGraph is based on key-value model)

label inheritance of AgensGraph

Above image show simple label model using inherits. For example, Data created with label ‘c’ can be access by label ‘a’ or label ‘c’.

create vlabel a;    -- parent 'a'
create vlabel b;    -- parent 'b'
create vlabel c inherits (a, b);    -- child 'c' 

Label of graph data (vertex or edge) can be retrieved using label and labels function. (ref. AgensGraph manual)

  • label(data) : show lowest label of data
  • labels(data) : show all labels of data with array format

This is another example about label modeling. When you want data fabric of merging from DB1 and DB2, each DB have tables having same name. If you need to access all data of table having same name and sub-data of one DB, what can you do? Let’s see this query.

cypher query example using labels function in AgensGraph

We first make label about two datasource. And label ‘Person’ is the real label we want for importing data from two datasource. But importing data must be distinguished each other. So we create two child labels inherited label ‘Person’ and datasources’ labels.

From now, imported data with child label can be accessed by label ‘Person’ and label ‘DB1’/’DB2’. And you can access all person data by label ‘Person’ or all data from DB1 by label ‘DB1’.

label hierarchy modeling for data fabric

Label ‘Person’ means entity what you want describe in Graph model. You can query graph-search using cypher about all ‘Person’ data. Label ‘DB1’ and ‘DB2’ means datasource what you import data from. You can register new datasource and import data from that and drop all data of that datasource. If you want preprocessing specific person data of one datasource, you should access data by child label.

Enjoy graph-query with AgensGraph.

댓글 남기기

아래 항목을 채우거나 오른쪽 아이콘 중 하나를 클릭하여 로그 인 하세요: 로고

WordPress.com의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

Google photo

Google의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

Twitter 사진

Twitter의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

Facebook 사진

Facebook의 계정을 사용하여 댓글을 남깁니다. 로그아웃 /  변경 )

%s에 연결하는 중