Suppose I have a simple relationship like
CREATE (a:Company { name:"Apple" })-[:BUYS]->(b:Company { name:"Beats" })
Now I want to collect metadata on the :BUYS
relationship - which User created that Relationship and what are the sources that confirm this. For this I create a new node and connect the other nodes to it:
MATCH (a:Company { name:"Apple" }),(b:Company { name:"Beats" })
CREATE a-[:IS_BUYER]->(ab:Buyout { name:"Apple-Beats" })<-[:IS_SELLER]-b
MATCH (u:User { name:"Fred" }),(n1:Newspaper { name:"Washington Post" }),
(n2:Newspaper { name:"Financial Times" }),(ab:Buyout { name:"Apple-Beats" })
CREATE u-[:CREATED]->ab<-[:CONFIRMED_BY]-n1,ab-[:CONFIRMED_BY]->n2
Now I have several questions:
- Since in most cases queries are only interested in the
:BUYS
relationship, I leave that intact and get better performance for those queries, right? - Are there other, better ways to model this?
- What is a good way to generate the name/ID for the materialized node?
- Is there any way to cascade the deletion of the
:BUYS
relationship to the corresponding:Buyout
node?