This film continues the previous several introduction diagram database creation, has the question can I look at the previous two articles: http://www.cnblogs.com/rongyux/p/5537206.html
Four-figure database creation
1 Create a node person {name: "My name"}
" My Name " return me;
" Mystic River ", Released:1993}) RETURN movie;
2 Modifying properties
Change properties: movie.tagline = "We bury Our sins here, Dave. We wash them clean. "
MATCH (Movie:movie) WHERE movie.title="mysticRiver""We Bury our sins here, Dave. We wash them clean. " RETURN movie;
Change: movie.released = 2003
MATCH (Movie:movie) WHERE movie.title="mysticRiver"2003 RETURN movie;
3 Increase relationship-side
MATCH (Me:person), (Movie:movie) WHERE me.name="My name" and movie.title="Mystic River "CREATE (Me)-[:reviewed {rating:summary:"tragic character Movie"}]-> (movie);
Another way to do this:
MATCH (Me:person {name:"My name"}), (Movie:movie {title:" MysticRiver"}) CREATE (Me)-[:reviewed {rating:summary:" Tragic character movie"}]-> (movie);
4merge: If this side is not present, increase the relationship:
MATCH (Clint:person), (Mystic:movie) WHERE clint.name="Clint Eastwood" and mystic.title="mystic River " MERGE (Clint)-[:D irected]->(mystic) RETURN Clint, mystic;
A more complicated example:
Increased understanding knows relationship: A film actor and actor, actor or director, or director and Director may know:
MATCH (a)-[:acted_in|:D Irected]-> () <-[:acted_in|:D irected]-(b) WHERE not (a)-[:knows]-(b) MERGE (a)-[:knows]-> (b);
5 deleting nodes and edges
Match (Me:person {name="My name"}) OPTIONAL match (Me)-[r]-() DELETE me,r;
6 Length level output
MATCH (Node1)-[*]-(Node2)
eg MATCH (Node1)-[*1..3]-(node2): output of three length levels
shortestPath
The 7 function returns the path with the shortest route length
MATCH P=shortestpath ((node1)-[*]-(node2)) RETURN Length (p), nodes (p)
NEO4J: Graph database Graphdb (iii)