Suppose we have person entity and trip relation to destination entity like city , and we wanna add 3 or 4 kind of information like transportation( type , ticket number , date , .. ) ,that must be node as itself to this relation ..
The question is how we can graph this?
It is not possible to have more than 2 nodes connected to a single relationship.
However, as a workaround, you can "reify" a relationship type as a node label, and create extra relationship types to connect to that new label.
For example, if your current data model is as follows:
(p:Person)-[:TRIP_TO]->(c:City), (transp:Transporation)
and you want to also associate each TRIP_TO
relationship with a Transportation
node, you can reify the TRIP_TO
relationship by replacing -[:TRIP_TO]->
with -[:TAKES]->(trip:Trip)-[:TO]->
, like so:
(p)-[:TAKES]->(trip:Trip)-[:TO]->(c)
and adding another new relationship type to connect the Trip
node to the appropriate Transportation
node:
(trip)-[:USES]->(transp)