cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Storing information sources in relationship properties

Hi all. I'm fairly new to Neo4j, but am very much enjoying figuring it all out. I was hoping for a little guidance on my use case.

I'm storing the source of information as properties in relationships between nodes. Take the following relationship for example: "(company)-[EMPLOYS]->(person)." I would create a relationship property with the information source and a timestamp for when it was gathered. This all works well and is intuitive, at least to me, from a information design perspective.

The challenge is that if multiple information sources confirm the same thing, I would like to store those multiple information sources and their respective timestamps in the relationship properties. I suspect I could use an array of JSON to do this, but will it be possible to query/update that information? For example, I'd like to be able to return matches with multiple information sources and also to check/update the timestamps for specific information sources.

Is an array of JSON the best way to do this? If so, how might I go about using that in future queries/updates?

Any advice would be much appreciated!

1 ACCEPTED SOLUTION

One thing that will get in the way of that is that we don't support complex structures as properties. For structures, we support lists, but not lists of lists or lists of maps.

While you can store JSON strings, you won't be able to explore that as a structure until you convert it from a string to a structure in your query.

You might also consider that if the relationships are important enough, maybe they deserve to be represented as a node instead.

Given your example, consider that an :Employment node would make sense, with start and end dates for employment, as well as a links to the employee and the place where they're employed.

View solution in original post

2 REPLIES 2

One thing that will get in the way of that is that we don't support complex structures as properties. For structures, we support lists, but not lists of lists or lists of maps.

While you can store JSON strings, you won't be able to explore that as a structure until you convert it from a string to a structure in your query.

You might also consider that if the relationships are important enough, maybe they deserve to be represented as a node instead.

Given your example, consider that an :Employment node would make sense, with start and end dates for employment, as well as a links to the employee and the place where they're employed.

Thanks for the reply, Andrew. That's all super helpful info. After further consideration, I think that I'm going to create a separate property for each source (source_x, source_y, etc) that contains the timestamp the information was retrieved from the source. That will allow easy querying/updating and not require additional nodes. Thanks again.