기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
Neptune GraphMappingConfig 생성
생성한 GraphMappingConfig
는 소스 데이터 스토어에서 추출한 데이터를 Neptune DB 클러스터에 로드하는 방법을 지정합니다. 형식은 RDF 데이터를 로드하는 데 사용할지 속성 그래프 데이터를 로드하는 데 사용할지 여부에 따라 다릅니다.
RDF 데이터의 경우 RDF에 관계형 데이터를 매핑하기 위해 W3 R2RML
Gremlin을 사용하여 쿼리할 속성 그래프 데이터를 로드하는 경우 GraphMappingConfig
에 대한 JSON 객체를 생성합니다.
RDF/SPARQL 데이터를 위한 GraphMappingConfig 레이아웃
SPARQL을 사용하여 쿼리할 RDF 데이터를 로드하는 경우 R2RMLGraphMappingConfig
를 작성합니다. R2RML
은 관계형 데이터를 RDF에 매핑하기 위한 표준 W3 언어입니다. 다음은 한 가지 예입니다.
@prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix ex: <http://example.com/ns#> . <#TriplesMap1> rr:logicalTable [ rr:tableName "nodes" ]; rr:subjectMap [ rr:template "http://data.example.com/employee/{id}"; rr:class ex:Employee; ]; rr:predicateObjectMap [ rr:predicate ex:name; rr:objectMap [ rr:column "label" ]; ] .
다음은 또 다른 예입니다.
@prefix rr: <http://www.w3.org/ns/r2rml#> . @prefix ex: <http://example.com/#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <#TriplesMap2> rr:logicalTable [ rr:tableName "Student" ]; rr:subjectMap [ rr:template "http://example.com/{ID}{Name}"; rr:class foaf:Person ]; rr:predicateObjectMap [ rr:predicate ex:id ; rr:objectMap [ rr:column "ID"; rr:datatype xsd:integer ] ]; rr:predicateObjectMap [ rr:predicate foaf:name ; rr:objectMap [ rr:column "Name" ] ] .
R2RML: RDB to RDF Mapping Language
Property-Graph/Gremlin 데이터용 GraphMappingConfig 레이아웃
속성 그래프 데이터의 비슷한 GraphMappingConfig
는 소스 데이터에서 생성될 각 그래프 엔티티에 대한 매핑 규칙을 제공하는 JSON 객체입니다. 다음 템플릿에서는 이 객체의 각 규칙이 어떻게 표시되는지 보여줍니다.
{ "rules": [ { "rule_id": "(an identifier for this rule)", "rule_name": "(a name for this rule)", "table_name": "(the name of the table or view being loaded)", "vertex_definitions": [ { "vertex_id_template": "{col1}", "vertex_label": "(the vertex to create)", "vertex_definition_id": "(an identifier for this vertex)", "vertex_properties": [ { "property_name": "(name of the property)", "property_value_template": "{col2} or text", "property_value_type": "(data type of the property)" } ] } ] }, { "rule_id": "(an identifier for this rule)", "rule_name": "(a name for this rule)", "table_name": "(the name of the table or view being loaded)", "edge_definitions": [ { "from_vertex": { "vertex_id_template": "{col1}", "vertex_definition_id": "(an identifier for the vertex referenced above)" }, "to_vertex": { "vertex_id_template": "{col3}", "vertex_definition_id": "(an identifier for the vertex referenced above)" }, "edge_id_template": { "label": "(the edge label to add)", "template": "{col1}_{col3}" }, "edge_properties":[ { "property_name": "(the property to add)", "property_value_template": "{col4} or text", "property_value_type": "(data type like String, int, double)" } ] } ] } ] }
버텍스 레이블이 존재한다는 것은 여기에 버텍스가 생성되고 있음을 의미하지만, 이 레이블이 없으면 버텍스가 다른 소스에 의해 생성되었음을 의미하며 이 정의는 버텍스 속성만 추가합니다.
다음은 직원 레코드에 대한 샘플 규칙입니다.
{ "rules": [ { "rule_id": "1", "rule_name": "vertex_mapping_rule_from_nodes", "table_name": "nodes", "vertex_definitions": [ { "vertex_id_template": "{emp_id}", "vertex_label": "employee", "vertex_definition_id": "1", "vertex_properties": [ { "property_name": "name", "property_value_template": "{emp_name}", "property_value_type": "String" } ] } ] }, { "rule_id": "2", "rule_name": "edge_mapping_rule_from_emp", "table_name": "nodes", "edge_definitions": [ { "from_vertex": { "vertex_id_template": "{emp_id}", "vertex_definition_id": "1" }, "to_vertex": { "vertex_id_template": "{mgr_id}", "vertex_definition_id": "1" }, "edge_id_template": { "label": "reportsTo", "template": "{emp_id}_{mgr_id}" }, "edge_properties":[ { "property_name": "team", "property_value_template": "{team}", "property_value_type": "String" } ] } ] } ] }