-
Notifications
You must be signed in to change notification settings - Fork 14
Neo4j Export
Philipp edited this page Oct 23, 2023
·
3 revisions
The Neo4j export transforms the ER model to a corresponding graph representation using the Cypher Query Language. Entities are mapped to nodes, relationships to edges between the nodes, and attributes are included as properties. For primary key attributes, uniqueness constraints are added to ensure that property values are unique for all nodes with the respective label.
The current export approach both sets the (pre-defined in Neo4j)
name
property and adds a label to the respective element (e.g.,:E1
). As a consequence, attributes are renamed to include the element's name as a prefix to avoid any naming collisions. Feel free to open a new issue if you have any suggestions for improving the transformation.
ER Model
erdiagram BasicExample
entity E1 {
a1: int key
a2: string
}
entity E2 {
a3: int key
a4: double
}
relationship R1 {
E1[1] -> E2[N]
}
Neo4j Export
// entities
CREATE (E1:E1 {name: "E1", E1_a1: "int", E1_a2: "string"})
CREATE (E2:E2 {name: "E2", E2_a3: "int", E2_a4: "double"})
// relationships
CREATE (E1)-[R1:R1 {name: "R1" }]->(E2)
// extends relationships (IS_A)
// constraints
CREATE CONSTRAINT IF NOT EXISTS FOR (x:E1) REQUIRE x.E1_a1 IS UNIQUE;
CREATE CONSTRAINT IF NOT EXISTS FOR (x:E2) REQUIRE x.E2_a3 IS UNIQUE;

Usage
Development