티스토리 뷰

RDF 데이터가 Neo4j에 저장되는 방식 

즉, Triple 형태가 PropertyGraph 형태로 저장되는 방식에 대해서 이야기 해보고자 한다.

 

Subject에 대한 것과 Property에 대한 것으로 크게 구분되며, Property는 ObjectProperty인 경우와 DatatypeProperty인 경우로 나뉘어 진다.

 

먼저 Subject인 경우를 살펴보자

트리플의 Subject는 PropertyGraph에서 Node로 매핑이 된다.

그 노드의 label은 :Resource로 생성이 되어지고, 이전 포스팅에서 이야기한 GraphConfig 설정에 따라 달라지겠지만

subject의 rdf:type으로 연결된 클래스의 uri가 Node의 label로 매핑될 수도 있다.

다시 말해 Subject에서 매핑되어 생성된 노드의 label은 Resource와 Subject의 rdf:type 클래스 uri가 될 수 있다는 말이다.

그리고 Subject의 uri는 Node의 property로 생성이 된다. property key는 uri, value는 uri 실제값이 된다.

 

아래의 예시를 통해 매핑되는 값을 살펴보자.

 

<RDF data (ttl 형식)>

:st_1

      rdf:type :Student ;

      rdfs:label "홍길동"^^xsd:string ;

      :birthYear 2000 ;

      :hobby  "축구"^^xsd:string , "농구"^^xsd:string ;

      :liveIn :ct_2 ;

      :major  "컴퓨터공학과"@ko ;

      :sex    "남자"^^xsd:string ;

      :take   :cs_1 , :cs_3 .

 

<Neo4j 매핑>

{

  "identity": 448,

  "labels": [ "Resource", “ns0__Student" ],

  "properties": {

    "uri": "http://joyhong.tistory.com/example/st_1"

  }

}

* ns0__ prefix 처리 설정에 따라 변경됨. GraphConfighandleVocabUris 부분 참조

 

이 때 반드시 제약사항으로 labelResource 노드의 property  uri 는 유일한 값으로 식별하도록 하여 uri 가 동일할 경우 새로운 노드가 생성되지 않도록 한다.

 

 

다음은 Property에 대한 매핑으로 ObjectProperty, DatatypeProperty 각각에 따라 다른 매핑이 적용된다.

DatatypeProperty인 경우를 보면 Subject 통해 매핑된 노드의 propertyDatatypeProperty가 매핑된다. 

literalobject 값은 노드의 propertyvalue로 생성된다.

 

<RDF data (ttl 형식)>

:st_1

      rdf:type :Student ;

      rdfs:label "홍길동"^^xsd:string ;

      :birthYear 2000 ;

      :hobby  "축구"^^xsd:string , "농구"^^xsd:string ;

      :liveIn :ct_2 ;

      :major  "컴퓨터공학과"@ko ;

      :sex    "남자"^^xsd:string ;

      :take   :cs_1 , :cs_3 .

 

<Neo4j 매핑>

{

  "identity": 448,

  "labels": [ "Resource", "ns0__Student" ],

  "properties": {

    "ns0__sex": "남자",

    "rdfs__label": "홍길동",

    "ns0__hobby": [ "축구", "농구" ],

    "ns0__major": "컴퓨터공학과",

    "ns0__birthYear": 2000,

    "uri": "http://joyhong.tistory.com/example/st_1"

  }

}

 

ObjectProperty 인 경우는 Propertyrelationship으로 매핑하고 property와 연결되는 object노드로 생성한다.

 

<RDF data (ttl 형식)>

:st_1

      rdf:type :Student ;

      rdfs:label "홍길동"^^xsd:string ;

      :birthYear 2000 ;

      :hobby  "축구"^^xsd:string , "농구"^^xsd:string ;

      :liveIn :ct_2 ;

      :major  "컴퓨터공학과"@ko ;

      :sex    "남자"^^xsd:string ;

      :take   :cs_1 , :cs_3 .

 

<Neo4j 매핑>

liveIn과 take가 관계(Relationship)으로 생성되고 liveIn과 take의 Object가 노드로 생성된 것을 볼 수 있다.

 

여기까지 RDF 데이터를 Neo4j에 저정할 때 매핑되는 방식에 대해 포스팅을 하였고 다음으로는 실 데이터를 import 하는 것과 GraphConfig 설정에 따른 결과가 어떻게 변경되는지에 대해 살펴보도록 하겠다.

 


참조 :

https://neo4j.com/docs/labs/nsmntx/current/

 

'Neo4j' 카테고리의 다른 글

FUll-text search  (0) 2020.06.17
Import RDF  (0) 2020.06.17
그래프 구성 설정  (0) 2020.06.17
Neosemantics  (0) 2020.06.17
IMPORT CSV  (2) 2020.06.17
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함