RGMapping Configuration

This section will specifically cover the definition rules in RGMapping. If you are not familiar with RGMapping, please refer to this section.

SQL/PGQ

In the context of transitioning from relational models to graph models, the process often involves mapping tables and their relationships into nodes (vertices) and edges within a property graph. The syntax provided seems to be an illustrative example of how one might define this transformation using a hypothetical SQL-like or extended SQL syntax, tailored specifically for creating property graphs. Let’s break down the conceptual structure behind such a conversion rule definition, though please note that the exact syntax you’ve shown is not standard SQL but appears to be inspired by extensions like PostgreSQL’s PGQ or other graph database management systems.

The RGMapping rule can be written in SQL/PGQ.

 1CREATE PROPERTY GRAPH ldbc
 2VERTEX TABLES (
 3    "PERSON"
 4    KEY ( "p_id" )
 5    LABEL "person" PROPERTIES ( p_id AS "p_id", name AS "p_name" )
 6)
 7EDGE TABLES (
 8    "TRANSFER"
 9    SOURCE KEY ( "P_ID1" ) REFERENCES "PERSON"
10    DESTINATION KEY ( "P_ID2" ) REFERENCES "PERSON"
11    LABEL "transfer" PROPERTIES ( t_data AS "t_date" )
12)

When defining the rules for converting a relational schema to a property graph model, several key components are typically addressed:

  1. Graph Declaration

    • This initiates the creation of a new graph database object. Example: CREATE PROPERTY GRAPH ldbc

  2. Vertex Tables Definition

    • Table Naming: Specifies which relational tables will be represented as vertex types in the graph. Example: "PERSON"

    • Key Definition: Determines the primary key column(s) of the table which will serve as the unique identifier (ID) for vertices. Example: KEY ( "p_id" )

    • Label Assignment: Assigns a label to the vertex type, reflecting its role or category in the graph. Example: LABEL "person"

    • Properties Mapping: Maps columns from the relational table to properties on the vertex, maintaining data integrity. Example: PROPERTIES ( p_id AS "p_id", name AS "p_name" )

  3. Edge Tables Definition

    • Table Naming: Identifies the relational table representing relationships between vertices. Example: "TRANSFER"

    • Source and Destination Key Definition: Specifies the columns in the edge table that refer to the start (source) and end (destination) vertices of the edge, usually referencing the primary keys of the vertex tables. Example: SOURCE KEY ( "P_ID1" ) REFERENCES "PERSON" and DESTINATION KEY ( "P_ID2" ) REFERENCES "PERSON"

    • Label Assignment: Assign a label to the edge type, describing the nature of the relationship. Example: LABEL "transfer"

    • Properties Mapping: Maps additional columns to properties on the edge, capturing details about the relationship. Example: PROPERTIES ( t_data AS "t_date" )

YAML

The RGMapping rule can also be written in YAML. The examples we give are equivalent conversion conditions to those described above for SQL/PGQ.

 1!!gart.pgql.GSchema
 2graph: ldbc
 3database: ldbc
 4enableRowStore: false
 5vertexMappings:
 6    vertex_types:
 7        - type_name: person
 8          dataSourceName: PERSON
 9          idFieldName: p_id
10          mappings:
11            - property: p_id
12              dataField:
13                  name: P_ID
14            - property: p_name
15              dataField:
16                  name: NAME
17edgeMappings:
18    edge_types:
19        - type_pair:
20            edge: transfer
21            source_vertex: person
22            destination_vertex: person
23          dataSourceName: TRANSFER
24          sourceVertexMappings:
25            - dataField:
26                  name: P_ID1
27          destinationVertexMappings:
28            - dataField:
29                  name: P_ID2
30          dataFieldMappings:
31            - property: t_date
32              dataField:
33                  name: T_DATA
  1. Graph Declaration

    • This initiates the creation of a new graph database object. Example: graph: ldbc

  2. Vertex Tables Definition (vertexMappings.vertex_types)

    • Table Naming: Specifies which relational tables will be represented as vertex types in the graph. Example: dataSourceName

    • Key Definition: Determines the primary key column(s) of the table which will serve as the unique identifier (ID) for vertices. Example: idFieldName

    • Label Assignment: Assigns a label to the vertex type, reflecting its role or category in the graph. Example: type_name

    • Properties Mapping: Maps columns from the relational table to properties on the vertex, maintaining data integrity. Example: mappings

  3. Edge Tables Definition (edgeMappings.edge_types)

    • Table Naming: Identifies the relational table representing relationships between vertices. Example: "TRANSFER"

    • Source and Destination Key Definition: Specifies the columns in the edge table that refer to the start (source) and end (destination) vertices of the edge, usually referencing the primary keys of the vertex tables. Example: type_pair, sourceVertexMappings, destinationVertexMappings

    • Label Assignment: Assign a label to the edge type, describing the nature of the relationship. Example: edge

    • Properties Mapping: Maps additional columns to properties on the edge, capturing details about the relationship. Example: dataFieldMappings