Map your tabular data into graph entities
This feature is experimental and not ready for use in production. It is only available as part of an Early Access Program, and can go under breaking changes until general availability. |
Once the data is prepared, we need to create a mapping model that maps our tables and columns into graph entities. The model is defined as a JSON file.
Model for our sample data
{
"name": "example", (1)
"db": "neo4j", (2)
"nodes": [ (3)
{
"source": "USERS", (4)
"label": "User", (5)
"key_field": "node_id", (6)
"properties": { (7)
"id": "id",
"age": "age",
"up_votes": "up_votes"
}
},
{
"source": "QUESTIONS",
"label": "Question",
"key_field": "node_id",
"properties": {
"id": "id",
"view_count": "view_count"
}
},
{
"source": "ANSWERS",
"label": "Answer",
"key_field": "node_id",
"properties": {
"id": "id"
}
}
],
"edges": [ (8)
{
"source": "QUESTIONS", (9)
"type": "ASKED", (10)
"source_field": "user_node_id", (11)
"target_field": "node_id", (12)
"properties": {} (13)
},
{
"source": "ANSWERS",
"type": "ANSWERED",
"source_field": "user_node_id",
"target_field": "node_id",
"properties": {}
},
{
"source": "ANSWERS",
"type": "HAS_ANSWER",
"source_field": "question_node_id",
"target_field": "node_id",
"properties": {}
}
]
}
1 | Name of graph projection, will be overridden by graph_name argument to the stored procedure. |
2 | Name of database that the graph projection will be created in, will be overridden by neo4j_db_name argument gathered from secrets. |
3 | List of node mappings. |
4 | Name of the source table. Could be specified as a regular expression. |
5 | Static label to use for the projected node records.
Could also be replaced by label_field property which describes a column of type STRING or ARRAY<STRING> which retrieves the label(s) from the data. |
6 | Defines column to be used as the unique identifier. |
7 | List of properties to attach to the projected node, mapped from source column to node property. |
8 | List of relationship mappings. |
9 | Name of the source table. Could be specified as a regular expression. |
10 | Static relationship type to use for the projected relationship records.
Could also be replaced by type_field property which describes a column of type STRING which retrieves the relationship type from the data. |
11 | Defines the column to be used to identify the source node. |
12 | Defines the column to be used to identify the target node. |
13 | List of properties to attach to the projected relationship, mapped from source column to node property. |
Note that Neo4j GDS/AuraDS only supports Refer to Supported types for a full list of supported types in Neo4j GDS/AuraDS. |
Once you are happy with the mapping, save it as a file into a Google Cloud Storage bucket, e.g. gs://<your-bucket-name>/my-graph-model.json