Basic operation of graphical database neo4j

Source: Internet
Author: User
Tags ming neo4j

1. Create a Node

1 syntax: CREATE (Node-name:label-name{property1-name:property1-value,... Propertyn-name:propertyn-value})2 such as:3 Create (Genre: Ming Party {name: ' Zhang Mowgli ', skill: ' Nine Yang Canon '})

2. Establish a relationship for two nodes

1 syntax: CREATE (NODE1:LABEL1)-[relationship-name:relationship-label-name]-> (NODE2:LABEL2) 2 such as: 3 Match (P: Wudang), (s: Ming party) where p.name = ' Zhang Trixan ' and s.name = ' Mowgli ' Create (P)-[r: Parent-Child]-> (s)   //establish relationship for two nodes 4 m Atch (P1: Emei faction), (P2: Emei faction) where P1.name = ' extermination division too ' and p2.name = ' Zhou Zhijo ' Create (p1)-[r: Apprentice]-> (p2) return R   //For two nodes, and return off System diagram

As shown in the following:

3. Find the diagram based on the specified relationship and node

1 syntax: Match r= (Node1:label1)-[relationship-name:relationship-label-name]-> (p2) return R 2 such as: 3 Match r= (P1: Emei faction)-[r: Apprentice]-> (p2) return R   //Return to Emei faction with a master-pupil relationship of the node diagram

As shown in the following:

4. Delete a specified relationship of two nodes

1 syntax: MATCH (Node1:label1{property1:value1})-[relationship-name:relationship-label-name]-> (node2:label2{ property2:value2}) Delete R2 such as: Because Songqing book betrayed Wudang, Song and he severed the father-son relationship 3 MATCH (p1: Wudang {name: ' Song Far Bridge '})- [R: Father and Son]-> (p2: Wudang {name: ' songqing book '}) Delete R

After the deletion of the Atlas as shown below, the two people no longer have a parent-child relationship

5. Some of the other basic operations

1 return all nodes in the graphics database 2 match (n) return n; 3 4 Delete all nodes of the graphics database 5 Match (n) detach Delete n

Basic operation of graphical database neo4j

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.