Neo4J deep validate graph










1















DB have some amount of OrderItemType which have relations between one to another like INCOMPATIBLE and REQUIRED



We combining an order by linking OrderItemType to it with CONTAINS relation



Is it possible to make constraint to fail with validation error when trying to add new OrderItemType which is incompatible with another in graph and if required items is not present yet?



Target is just trying to insert, and get reject if it violate some conditions



Another option - using transaction:
1. insert item
2. load graph and check rules manually
3. rollback if find some problems



UPDATE
Ok I will rephrase question with standard movies sample



lets establish some relations between actors



CREATE (Keanu)-[:HATE]->(JackN),
(Keanu)-[:REQUIRE]->(LillyW),
(JamesM)-[:HATE]->(LillyW)


now we starting new movie producing



CREATE (RaiseOfCrazyDev:Movie title:'RaiseOfCrazyDev', released:2020, tagline:'Crazy developer conquer the world')


and start casting. first we sign JackN, and JamesM



CREATE (JackN)-[:ACTED_IN roles:['Father'] ]->(RaiseOfCrazyDev),
(JamesM)-[:ACTED_IN roles:['BadGuy'] ]->(RaiseOfCrazyDev)


now we try to sign Keanu



CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev)


But it should fail, since Keanu hates JackN, and Keanu require LillyW



so we remove JackN and add Keanu and LillyW instead



MATCH (:JackN)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r
CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev),
(LillyW)-[:ACTED_IN roles:['StepSister'] ]->(RaiseOfCrazyDev)


but now it fails again because JamesM hates LillyW



since Keanu is a main role in our movie, we fire JamesM



MATCH (:JamesM)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r


So, if rephrase:



  • It should be no HATE relationship between any two actors attached to one movie

  • For all actors their REQUIRE relationship should be actors in this movie too.

Question: What is the best way and place to make such conditions checks?










share|improve this question
























  • Can you provide a Cypher query that generates some data in your data model?

    – cybersam
    Nov 13 '18 at 23:24











  • added example based on movie sample

    – Alexander Popov
    Nov 14 '18 at 11:07











  • Can the DB contain problematic situations like: a requires b, and b requires c, but c hates a? Or would you prevent such situations from being introduced?

    – cybersam
    Nov 14 '18 at 19:58











  • prevent. Error should happens with enough details and UI will resolve problem

    – Alexander Popov
    Nov 14 '18 at 20:03















1















DB have some amount of OrderItemType which have relations between one to another like INCOMPATIBLE and REQUIRED



We combining an order by linking OrderItemType to it with CONTAINS relation



Is it possible to make constraint to fail with validation error when trying to add new OrderItemType which is incompatible with another in graph and if required items is not present yet?



Target is just trying to insert, and get reject if it violate some conditions



Another option - using transaction:
1. insert item
2. load graph and check rules manually
3. rollback if find some problems



UPDATE
Ok I will rephrase question with standard movies sample



lets establish some relations between actors



CREATE (Keanu)-[:HATE]->(JackN),
(Keanu)-[:REQUIRE]->(LillyW),
(JamesM)-[:HATE]->(LillyW)


now we starting new movie producing



CREATE (RaiseOfCrazyDev:Movie title:'RaiseOfCrazyDev', released:2020, tagline:'Crazy developer conquer the world')


and start casting. first we sign JackN, and JamesM



CREATE (JackN)-[:ACTED_IN roles:['Father'] ]->(RaiseOfCrazyDev),
(JamesM)-[:ACTED_IN roles:['BadGuy'] ]->(RaiseOfCrazyDev)


now we try to sign Keanu



CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev)


But it should fail, since Keanu hates JackN, and Keanu require LillyW



so we remove JackN and add Keanu and LillyW instead



MATCH (:JackN)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r
CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev),
(LillyW)-[:ACTED_IN roles:['StepSister'] ]->(RaiseOfCrazyDev)


but now it fails again because JamesM hates LillyW



since Keanu is a main role in our movie, we fire JamesM



MATCH (:JamesM)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r


So, if rephrase:



  • It should be no HATE relationship between any two actors attached to one movie

  • For all actors their REQUIRE relationship should be actors in this movie too.

Question: What is the best way and place to make such conditions checks?










share|improve this question
























  • Can you provide a Cypher query that generates some data in your data model?

    – cybersam
    Nov 13 '18 at 23:24











  • added example based on movie sample

    – Alexander Popov
    Nov 14 '18 at 11:07











  • Can the DB contain problematic situations like: a requires b, and b requires c, but c hates a? Or would you prevent such situations from being introduced?

    – cybersam
    Nov 14 '18 at 19:58











  • prevent. Error should happens with enough details and UI will resolve problem

    – Alexander Popov
    Nov 14 '18 at 20:03













1












1








1


1






DB have some amount of OrderItemType which have relations between one to another like INCOMPATIBLE and REQUIRED



We combining an order by linking OrderItemType to it with CONTAINS relation



Is it possible to make constraint to fail with validation error when trying to add new OrderItemType which is incompatible with another in graph and if required items is not present yet?



Target is just trying to insert, and get reject if it violate some conditions



Another option - using transaction:
1. insert item
2. load graph and check rules manually
3. rollback if find some problems



UPDATE
Ok I will rephrase question with standard movies sample



lets establish some relations between actors



CREATE (Keanu)-[:HATE]->(JackN),
(Keanu)-[:REQUIRE]->(LillyW),
(JamesM)-[:HATE]->(LillyW)


now we starting new movie producing



CREATE (RaiseOfCrazyDev:Movie title:'RaiseOfCrazyDev', released:2020, tagline:'Crazy developer conquer the world')


and start casting. first we sign JackN, and JamesM



CREATE (JackN)-[:ACTED_IN roles:['Father'] ]->(RaiseOfCrazyDev),
(JamesM)-[:ACTED_IN roles:['BadGuy'] ]->(RaiseOfCrazyDev)


now we try to sign Keanu



CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev)


But it should fail, since Keanu hates JackN, and Keanu require LillyW



so we remove JackN and add Keanu and LillyW instead



MATCH (:JackN)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r
CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev),
(LillyW)-[:ACTED_IN roles:['StepSister'] ]->(RaiseOfCrazyDev)


but now it fails again because JamesM hates LillyW



since Keanu is a main role in our movie, we fire JamesM



MATCH (:JamesM)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r


So, if rephrase:



  • It should be no HATE relationship between any two actors attached to one movie

  • For all actors their REQUIRE relationship should be actors in this movie too.

Question: What is the best way and place to make such conditions checks?










share|improve this question
















DB have some amount of OrderItemType which have relations between one to another like INCOMPATIBLE and REQUIRED



We combining an order by linking OrderItemType to it with CONTAINS relation



Is it possible to make constraint to fail with validation error when trying to add new OrderItemType which is incompatible with another in graph and if required items is not present yet?



Target is just trying to insert, and get reject if it violate some conditions



Another option - using transaction:
1. insert item
2. load graph and check rules manually
3. rollback if find some problems



UPDATE
Ok I will rephrase question with standard movies sample



lets establish some relations between actors



CREATE (Keanu)-[:HATE]->(JackN),
(Keanu)-[:REQUIRE]->(LillyW),
(JamesM)-[:HATE]->(LillyW)


now we starting new movie producing



CREATE (RaiseOfCrazyDev:Movie title:'RaiseOfCrazyDev', released:2020, tagline:'Crazy developer conquer the world')


and start casting. first we sign JackN, and JamesM



CREATE (JackN)-[:ACTED_IN roles:['Father'] ]->(RaiseOfCrazyDev),
(JamesM)-[:ACTED_IN roles:['BadGuy'] ]->(RaiseOfCrazyDev)


now we try to sign Keanu



CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev)


But it should fail, since Keanu hates JackN, and Keanu require LillyW



so we remove JackN and add Keanu and LillyW instead



MATCH (:JackN)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r
CREATE (Keanu)-[:ACTED_IN roles:['Dev'] ]->(RaiseOfCrazyDev),
(LillyW)-[:ACTED_IN roles:['StepSister'] ]->(RaiseOfCrazyDev)


but now it fails again because JamesM hates LillyW



since Keanu is a main role in our movie, we fire JamesM



MATCH (:JamesM)-[r:ACTED_IN]-(:RaiseOfCrazyDev) DELETE r


So, if rephrase:



  • It should be no HATE relationship between any two actors attached to one movie

  • For all actors their REQUIRE relationship should be actors in this movie too.

Question: What is the best way and place to make such conditions checks?







neo4j






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 11:17







Alexander Popov

















asked Nov 13 '18 at 22:07









Alexander PopovAlexander Popov

12711




12711












  • Can you provide a Cypher query that generates some data in your data model?

    – cybersam
    Nov 13 '18 at 23:24











  • added example based on movie sample

    – Alexander Popov
    Nov 14 '18 at 11:07











  • Can the DB contain problematic situations like: a requires b, and b requires c, but c hates a? Or would you prevent such situations from being introduced?

    – cybersam
    Nov 14 '18 at 19:58











  • prevent. Error should happens with enough details and UI will resolve problem

    – Alexander Popov
    Nov 14 '18 at 20:03

















  • Can you provide a Cypher query that generates some data in your data model?

    – cybersam
    Nov 13 '18 at 23:24











  • added example based on movie sample

    – Alexander Popov
    Nov 14 '18 at 11:07











  • Can the DB contain problematic situations like: a requires b, and b requires c, but c hates a? Or would you prevent such situations from being introduced?

    – cybersam
    Nov 14 '18 at 19:58











  • prevent. Error should happens with enough details and UI will resolve problem

    – Alexander Popov
    Nov 14 '18 at 20:03
















Can you provide a Cypher query that generates some data in your data model?

– cybersam
Nov 13 '18 at 23:24





Can you provide a Cypher query that generates some data in your data model?

– cybersam
Nov 13 '18 at 23:24













added example based on movie sample

– Alexander Popov
Nov 14 '18 at 11:07





added example based on movie sample

– Alexander Popov
Nov 14 '18 at 11:07













Can the DB contain problematic situations like: a requires b, and b requires c, but c hates a? Or would you prevent such situations from being introduced?

– cybersam
Nov 14 '18 at 19:58





Can the DB contain problematic situations like: a requires b, and b requires c, but c hates a? Or would you prevent such situations from being introduced?

– cybersam
Nov 14 '18 at 19:58













prevent. Error should happens with enough details and UI will resolve problem

– Alexander Popov
Nov 14 '18 at 20:03





prevent. Error should happens with enough details and UI will resolve problem

– Alexander Popov
Nov 14 '18 at 20:03












1 Answer
1






active

oldest

votes


















1














I assume that problematic situations like the following do not exist in the DB: a requires b, and b requires c, but c hates a. (Even though such situations can exist in real life :-)). I also assume that actor nodes have the Actor label and a name property.



This query should get you started. It will tell you if it is OK to add an actor (I assume that actorName and title are passed as parameters). It will also return a list of the current cast members opposed by the "required" actors (including the main actor you want to add, and all the actors required by the required actors, etc.), and a list of the required actors opposed by the current cast members:



MATCH (a:Actor name: $actorName), (m:Movie title: $title)
OPTIONAL MATCH p=(a)-[:REQUIRE*]->(:Actor)
WITH a, m, NODES(p) AS reqs
UNWIND reqs AS req
WITH DISTINCT a, m, reqs, req
OPTIONAL MATCH (req)-[:HATE]->(h:Actor)
WITH a, m, reqs, COLLECT(DISTINCT h) AS hatedByReq
OPTIONAL MATCH (m)<-[:ACTED_IN]-(x:Actor)
OPTIONAL MATCH (x)-[:HATE]->(y:Actor)
WITH a, m, reqs, hatedByReq, COLLECT(x) AS cast, COLLECT(DISTINCT y) AS hatedByCast
WITH a, m, [c IN cast WHERE c IN hatedByReq] AS reqOpposes, [r IN reqs WHERE r IN hatedByCast] AS castOpposes
RETURN a, m, reqOpposes, castOpposes, (SIZE(reqOpposes) = 0 AND SIZE(castOpposes) = 0) AS okToAddActors


The result, using your sample data, is:



╒════════════════╤══════════════════════════════════════════════════════════════════════╤══════════════════╤═══════════════════╤═══════════════╕
│"a" │"m" │"reqOpposes" │"castOpposes" │"okToAddActors"│
╞════════════════╪══════════════════════════════════════════════════════════════════════╪══════════════════╪═══════════════════╪═══════════════╡
│"name":"Keanu"│"title":"RaiseOfCrazyDev","tagline":"Crazy developer conquer the wor│["name":"JackN"]│["name":"LillyW"]│false │
│ │ld","released":2020 │ │ │ │
└────────────────┴──────────────────────────────────────────────────────────────────────┴──────────────────┴───────────────────┴───────────────┘





share|improve this answer























  • Thanks, good for start.

    – Alexander Popov
    Nov 15 '18 at 10:43











  • In order to have the query actually create the new relationships (assuming there is no opposition), you'd have to somehow supply the roles for every required actor that is not already in the cast. You will have to think about how to do that. I think this answer above is the best that can be done, without that info.

    – cybersam
    Nov 15 '18 at 18:46










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290234%2fneo4j-deep-validate-graph%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I assume that problematic situations like the following do not exist in the DB: a requires b, and b requires c, but c hates a. (Even though such situations can exist in real life :-)). I also assume that actor nodes have the Actor label and a name property.



This query should get you started. It will tell you if it is OK to add an actor (I assume that actorName and title are passed as parameters). It will also return a list of the current cast members opposed by the "required" actors (including the main actor you want to add, and all the actors required by the required actors, etc.), and a list of the required actors opposed by the current cast members:



MATCH (a:Actor name: $actorName), (m:Movie title: $title)
OPTIONAL MATCH p=(a)-[:REQUIRE*]->(:Actor)
WITH a, m, NODES(p) AS reqs
UNWIND reqs AS req
WITH DISTINCT a, m, reqs, req
OPTIONAL MATCH (req)-[:HATE]->(h:Actor)
WITH a, m, reqs, COLLECT(DISTINCT h) AS hatedByReq
OPTIONAL MATCH (m)<-[:ACTED_IN]-(x:Actor)
OPTIONAL MATCH (x)-[:HATE]->(y:Actor)
WITH a, m, reqs, hatedByReq, COLLECT(x) AS cast, COLLECT(DISTINCT y) AS hatedByCast
WITH a, m, [c IN cast WHERE c IN hatedByReq] AS reqOpposes, [r IN reqs WHERE r IN hatedByCast] AS castOpposes
RETURN a, m, reqOpposes, castOpposes, (SIZE(reqOpposes) = 0 AND SIZE(castOpposes) = 0) AS okToAddActors


The result, using your sample data, is:



╒════════════════╤══════════════════════════════════════════════════════════════════════╤══════════════════╤═══════════════════╤═══════════════╕
│"a" │"m" │"reqOpposes" │"castOpposes" │"okToAddActors"│
╞════════════════╪══════════════════════════════════════════════════════════════════════╪══════════════════╪═══════════════════╪═══════════════╡
│"name":"Keanu"│"title":"RaiseOfCrazyDev","tagline":"Crazy developer conquer the wor│["name":"JackN"]│["name":"LillyW"]│false │
│ │ld","released":2020 │ │ │ │
└────────────────┴──────────────────────────────────────────────────────────────────────┴──────────────────┴───────────────────┴───────────────┘





share|improve this answer























  • Thanks, good for start.

    – Alexander Popov
    Nov 15 '18 at 10:43











  • In order to have the query actually create the new relationships (assuming there is no opposition), you'd have to somehow supply the roles for every required actor that is not already in the cast. You will have to think about how to do that. I think this answer above is the best that can be done, without that info.

    – cybersam
    Nov 15 '18 at 18:46















1














I assume that problematic situations like the following do not exist in the DB: a requires b, and b requires c, but c hates a. (Even though such situations can exist in real life :-)). I also assume that actor nodes have the Actor label and a name property.



This query should get you started. It will tell you if it is OK to add an actor (I assume that actorName and title are passed as parameters). It will also return a list of the current cast members opposed by the "required" actors (including the main actor you want to add, and all the actors required by the required actors, etc.), and a list of the required actors opposed by the current cast members:



MATCH (a:Actor name: $actorName), (m:Movie title: $title)
OPTIONAL MATCH p=(a)-[:REQUIRE*]->(:Actor)
WITH a, m, NODES(p) AS reqs
UNWIND reqs AS req
WITH DISTINCT a, m, reqs, req
OPTIONAL MATCH (req)-[:HATE]->(h:Actor)
WITH a, m, reqs, COLLECT(DISTINCT h) AS hatedByReq
OPTIONAL MATCH (m)<-[:ACTED_IN]-(x:Actor)
OPTIONAL MATCH (x)-[:HATE]->(y:Actor)
WITH a, m, reqs, hatedByReq, COLLECT(x) AS cast, COLLECT(DISTINCT y) AS hatedByCast
WITH a, m, [c IN cast WHERE c IN hatedByReq] AS reqOpposes, [r IN reqs WHERE r IN hatedByCast] AS castOpposes
RETURN a, m, reqOpposes, castOpposes, (SIZE(reqOpposes) = 0 AND SIZE(castOpposes) = 0) AS okToAddActors


The result, using your sample data, is:



╒════════════════╤══════════════════════════════════════════════════════════════════════╤══════════════════╤═══════════════════╤═══════════════╕
│"a" │"m" │"reqOpposes" │"castOpposes" │"okToAddActors"│
╞════════════════╪══════════════════════════════════════════════════════════════════════╪══════════════════╪═══════════════════╪═══════════════╡
│"name":"Keanu"│"title":"RaiseOfCrazyDev","tagline":"Crazy developer conquer the wor│["name":"JackN"]│["name":"LillyW"]│false │
│ │ld","released":2020 │ │ │ │
└────────────────┴──────────────────────────────────────────────────────────────────────┴──────────────────┴───────────────────┴───────────────┘





share|improve this answer























  • Thanks, good for start.

    – Alexander Popov
    Nov 15 '18 at 10:43











  • In order to have the query actually create the new relationships (assuming there is no opposition), you'd have to somehow supply the roles for every required actor that is not already in the cast. You will have to think about how to do that. I think this answer above is the best that can be done, without that info.

    – cybersam
    Nov 15 '18 at 18:46













1












1








1







I assume that problematic situations like the following do not exist in the DB: a requires b, and b requires c, but c hates a. (Even though such situations can exist in real life :-)). I also assume that actor nodes have the Actor label and a name property.



This query should get you started. It will tell you if it is OK to add an actor (I assume that actorName and title are passed as parameters). It will also return a list of the current cast members opposed by the "required" actors (including the main actor you want to add, and all the actors required by the required actors, etc.), and a list of the required actors opposed by the current cast members:



MATCH (a:Actor name: $actorName), (m:Movie title: $title)
OPTIONAL MATCH p=(a)-[:REQUIRE*]->(:Actor)
WITH a, m, NODES(p) AS reqs
UNWIND reqs AS req
WITH DISTINCT a, m, reqs, req
OPTIONAL MATCH (req)-[:HATE]->(h:Actor)
WITH a, m, reqs, COLLECT(DISTINCT h) AS hatedByReq
OPTIONAL MATCH (m)<-[:ACTED_IN]-(x:Actor)
OPTIONAL MATCH (x)-[:HATE]->(y:Actor)
WITH a, m, reqs, hatedByReq, COLLECT(x) AS cast, COLLECT(DISTINCT y) AS hatedByCast
WITH a, m, [c IN cast WHERE c IN hatedByReq] AS reqOpposes, [r IN reqs WHERE r IN hatedByCast] AS castOpposes
RETURN a, m, reqOpposes, castOpposes, (SIZE(reqOpposes) = 0 AND SIZE(castOpposes) = 0) AS okToAddActors


The result, using your sample data, is:



╒════════════════╤══════════════════════════════════════════════════════════════════════╤══════════════════╤═══════════════════╤═══════════════╕
│"a" │"m" │"reqOpposes" │"castOpposes" │"okToAddActors"│
╞════════════════╪══════════════════════════════════════════════════════════════════════╪══════════════════╪═══════════════════╪═══════════════╡
│"name":"Keanu"│"title":"RaiseOfCrazyDev","tagline":"Crazy developer conquer the wor│["name":"JackN"]│["name":"LillyW"]│false │
│ │ld","released":2020 │ │ │ │
└────────────────┴──────────────────────────────────────────────────────────────────────┴──────────────────┴───────────────────┴───────────────┘





share|improve this answer













I assume that problematic situations like the following do not exist in the DB: a requires b, and b requires c, but c hates a. (Even though such situations can exist in real life :-)). I also assume that actor nodes have the Actor label and a name property.



This query should get you started. It will tell you if it is OK to add an actor (I assume that actorName and title are passed as parameters). It will also return a list of the current cast members opposed by the "required" actors (including the main actor you want to add, and all the actors required by the required actors, etc.), and a list of the required actors opposed by the current cast members:



MATCH (a:Actor name: $actorName), (m:Movie title: $title)
OPTIONAL MATCH p=(a)-[:REQUIRE*]->(:Actor)
WITH a, m, NODES(p) AS reqs
UNWIND reqs AS req
WITH DISTINCT a, m, reqs, req
OPTIONAL MATCH (req)-[:HATE]->(h:Actor)
WITH a, m, reqs, COLLECT(DISTINCT h) AS hatedByReq
OPTIONAL MATCH (m)<-[:ACTED_IN]-(x:Actor)
OPTIONAL MATCH (x)-[:HATE]->(y:Actor)
WITH a, m, reqs, hatedByReq, COLLECT(x) AS cast, COLLECT(DISTINCT y) AS hatedByCast
WITH a, m, [c IN cast WHERE c IN hatedByReq] AS reqOpposes, [r IN reqs WHERE r IN hatedByCast] AS castOpposes
RETURN a, m, reqOpposes, castOpposes, (SIZE(reqOpposes) = 0 AND SIZE(castOpposes) = 0) AS okToAddActors


The result, using your sample data, is:



╒════════════════╤══════════════════════════════════════════════════════════════════════╤══════════════════╤═══════════════════╤═══════════════╕
│"a" │"m" │"reqOpposes" │"castOpposes" │"okToAddActors"│
╞════════════════╪══════════════════════════════════════════════════════════════════════╪══════════════════╪═══════════════════╪═══════════════╡
│"name":"Keanu"│"title":"RaiseOfCrazyDev","tagline":"Crazy developer conquer the wor│["name":"JackN"]│["name":"LillyW"]│false │
│ │ld","released":2020 │ │ │ │
└────────────────┴──────────────────────────────────────────────────────────────────────┴──────────────────┴───────────────────┴───────────────┘






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 21:30









cybersamcybersam

39.4k43151




39.4k43151












  • Thanks, good for start.

    – Alexander Popov
    Nov 15 '18 at 10:43











  • In order to have the query actually create the new relationships (assuming there is no opposition), you'd have to somehow supply the roles for every required actor that is not already in the cast. You will have to think about how to do that. I think this answer above is the best that can be done, without that info.

    – cybersam
    Nov 15 '18 at 18:46

















  • Thanks, good for start.

    – Alexander Popov
    Nov 15 '18 at 10:43











  • In order to have the query actually create the new relationships (assuming there is no opposition), you'd have to somehow supply the roles for every required actor that is not already in the cast. You will have to think about how to do that. I think this answer above is the best that can be done, without that info.

    – cybersam
    Nov 15 '18 at 18:46
















Thanks, good for start.

– Alexander Popov
Nov 15 '18 at 10:43





Thanks, good for start.

– Alexander Popov
Nov 15 '18 at 10:43













In order to have the query actually create the new relationships (assuming there is no opposition), you'd have to somehow supply the roles for every required actor that is not already in the cast. You will have to think about how to do that. I think this answer above is the best that can be done, without that info.

– cybersam
Nov 15 '18 at 18:46





In order to have the query actually create the new relationships (assuming there is no opposition), you'd have to somehow supply the roles for every required actor that is not already in the cast. You will have to think about how to do that. I think this answer above is the best that can be done, without that info.

– cybersam
Nov 15 '18 at 18:46

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290234%2fneo4j-deep-validate-graph%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3