How can I bind an edge / relation to a node that contains information about that edge?

I need to store biological interactions in a Neo4j database. For example, consider a scenario where I have two types of nodes, Protein

and Experiment

and a relationship INTERACTS_WITH

. The connection exists as (Protein)-[INTERACTS_WITH]-(Protein)

. Now INTERACTS_WITH

also refers to Experiment

, because this biological interaction was observed in this experiment.

I need to associate a relationship INTERACTS_WITH

with Experiments

.

One way to achieve this would be to store the id of all such Experiments

in the relation's array type property INTERACTS_WITH

. But that would be like storing the Primary Key of an object as a Foreign Key of another object in a relational database, which I want to avoid.

Another way would be to create a Interaction

node for each pair of interacting genes and then link it to the two Proteins

and Experiments

. But the interaction is only possible between two nodes Protein

, so I have to put the software limit on the number of nodes Protein

belonging to the Interaction

node. This approach is also not good because it INTERACTS_WITH

is actually a relationship and it might not be practical to model it as a node.

Is there a better, graphical way to do this? If not, which of these two approaches would be better?

+3


source to share


1 answer


Another way would be to create an interaction node for each pair of interacting genes and then link them to two proteins and Experiments.

I think this is a very good approach to solve your problem.

But interaction is only possible between two protein nodes, so I will have to programmatically put a limit on the number of protein nodes that refer to the interaction of a node.

Nothing to do. Programmers do this all the time! For example: What guarantees do you have about how many INTERACTS_WITH relationships exist between two protein nodes? You probably took care of this during creation.



This approach is also not a good one, because INTERACTS_WITH is actually a relationship and it might not be practical to model it as a node.

Think about it: if your relationship INTERACTS_WITH

needs to be related to more than two nodes, perhaps you are modeling a node as a relationship, right?

Tip: Check out Graphical Modeling Best Practices and Pitfalls in Learning Neo4j (Rick Van Bruggen) and Common Modeling Errors in Graph Databases (Ian Robinson, Jim Webber, and Emil Eifrem). It can be enlightening. You can download two books from the Neo4j website here .

+2


source







All Articles