I am new to Neo4j, I am trying to create a node like so:
neo4_session.run("MERGE (t:Table {name: $name, columns: $columns}) ",
name=table['table_name'], columns=[{'colname':'a'},{'colname':'b'},{'colname':'c'}])
Neo4j tells me this:
neo4j.exceptions.CypherTypeError: Collections containing mixed types can not be stored in properties.
Which means it only allows me to have a list:
neo4_session.run("MERGE (t:Table {name: $name, columns: $columns}) ",
name=table['table_name'], columns=['a','b','c'])
However, each table node in my database will have different column names so I can't really have a list of properties...
Any advice?
I think you should consider using a :Column
node label instead of a list of columns in the :Table
node.
This way you can model your graph like this:
CREATE (table:Table {name : 'Table 1'})
CREATE (columnA:Column {colname : 'a'})
CREATE (columnB:Column {colname : 'b', otherProp: 'Other value'})
CREATE (columnC:Column {colname : 'c'})
CREATE (table)-[:CONTAINS]->(columnA)
CREATE (table)-[:CONTAINS]->(columnB)
CREATE (table)-[:CONTAINS]->(columnC)
Resulting on:
Also, this is a more "graphist" way to model your data.