Preliminary study of Cypher in neo4j

Source: Internet
Author: User
Tags neo4j

due to the need of RDF database, the need to investigate the graphical database, the choice of neo4j to try, found that it contains a "Cypher" the operation of the language, using the feeling is very good, all have to write something necessary. Steal a map from the official website:
      In fact, this diagram also identifies the basic functions of the Cypher language, Node A to Node B, the relationship is likes, its operation method and SQL Select the same as the choice of the entity to meet certain conditions, it is strongly recommended that you use the web version of familiar operation , more intuitive, can directly get graphics.       Gossip less, let's make it the universal formula, which is broadly divided into two parts () and [], where () indicates that a node can be considered a record in a relational database or an entity in RDF, [] The table is a relationship, This creates a relationship between the entity and the entity;      after matching and other operations based on the universal formula, the keyword match Return.      match (a) return a, meaning that all nodes are returned, where a is the way to define a variable;     match (A:person) return a, Returns the node for all person categories, where the person type is specified during node creation;      match (a:person:teacher)  return A, Returns all teacher nodes that belong to the person category (examples are a bit inappropriate), as we can see from this example we can see how many categories you can;      In addition, we can create nodes by creating;      create (:P erson {name: "Li Chen"}), create a node named Li Chen;     create (Fan:person {name: "Fan Bingbing"}) Return fan, create a node named Fan Bingbing, and return, from this inside we can see the type can be variable, it is necessary to note that even if you do not add type can still be declared;     match (Li:person {name: " Li Chen "})  match (Fan:person {name:" Fan Bingbing "})  create (fan)-[: Fix]-> (LI) return fan,li, complete the relationship, Fan Bingbing fix Li Chen;    Finally, one of the shortestpath that needs to be explained isName to find the shortest path, familiar with RDF probably can understand the Relfinder function, the two functions are similar, the vernacular is to find a small A and small B, they have no relationship between them, is through the Shortestpath method to achieve, is all over the relationship to specify a few degrees to infer the relationship ;    Match (A:person {name: "Small A"})  match (B:person {name: "Small B"})  p= shortpath ((a)-[: Friend *. 2]-> (b)) return a,b,p returns a possible path between all small A and small B to generate a friend relationship within two degrees.

Preliminary study of Cypher in neo4j

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.