Neo4j basis (detail)

web interface Basic Operations

  • create Create a node
    create (node-name: label- name {property-name: property-value})
    node eg create a single label, the node has four attributes


    1331259-a1fbbbf09321ae6f.png
    image.png

    Eg node to create multiple labels, the node has a property


    1331259-3fb9304124b4cf18.png
    image.png

    We continue to add some nodes to facilitate the following actions
    1331259-0939145cc65a281e.png
    image.png

    eg when creating a node at the same time set an association
    1331259-1a7b11d892a9e1c3.png
    image.png

    eg create an association to an existing node (Neo4j CQL CREATE command supports only the direction of the relationship)


    1331259-eee4337b5427d495.png
    image.png

    After eg return a node, you can view the nodes associated with him according to the association options node relationship information
    1331259-4e4a35849162fb59.png
    image.png

    eg when creating a node can only attribute required of a good design, but does not fill a specific value is set to NULL, use IS NULL late to find this node and set the desired value
    1331259-b3cec148eddc4a55.png
    image.png

    1331259-1e7dda06dfd702fb.png
    image.png
  • match lookup relationship, or find nodes
  • return operation display information obtained
    eg show all nodes


    1331259-f378452e38d606e4.png
    image.png

    eg to find a specific one node specific information


    1331259-6ec4835efa56a275.png
    image.png

    eg finding information a node of class
    1331259-afa1f7173a913170.png
    image.png

    eg find a class of node points in accordance with the label
    1331259-37843e91b04667ec.png
    image.png

    eg find nodes based on point properties


    1331259-fce936ce06b445f3.png
    image.png

    egMatch combined with the intermediate processing results
    1331259-c23e67c2c3436b23.png
    image.png

    eg node for multiple tabs, you can specify the label to find
    1331259-dc33c20fdc4b6a70.png
    image.png
  • Delete delete- or delete nodes associated with
    eg such as we build some relationship between students and found that clutter intend to delete just added Relations


    1331259-717173e84b186425.png
    image.png

    1331259-e08ff70ed667ef03.png
    image.png

    eg found Friends of the relationship between Sylvia and set Nile node problem, delete re-add relationship


    1331259-769c3b4b07b4f540.png
    image.png

    eg remove duplicate node
    1331259-fe3c18ed59739907.png
    image.png

    Appropriate to add some other relationship
    1331259-5a99cc9ae93c9afa.png
    image.png
  • Add or delete attributes (the SET, the Remove)
    EG added a tagline


    1331259-54604c998c17c3c2.png
    image.png

    eg add a property


    1331259-344e23488b9ebf77.png
    image.png

    eg remove a property
    1331259-8eecfd6a733872ba.png
    image.png

    Detach delete and delete: the former delete nodes and relationships, which just delete nodes

    eg delete tagline


    1331259-f802a1e3de3c1017.png
    image.png
  • tagline


    1331259-8e35175722945931.png
    image.png

    Tagline: Some feature node can not
    Property: attribute may be a node may be associated attributes
    Label: label, a node classification

  • Filter according to defined conditions where
  • Sort by the Order
    EG by name in descending order


    1331259-319f26d4acd2a086.png
    image.png
  • Union
    EG can see two queries before and after the Union needs to have the same column name


    1331259-987aa33562d7a25c.png
    image.png

    eg statistics teacher student id


    1331259-5982fd953d408048.png
    image.png
  • Limit
    EG limit display two nodes (according <id> ascending order of display)


    1331259-cd72aa505f9432b2.png
    image.png

    1331259-590d4a2fe0958969.png
    image.png

    1331259-32f6382bf11d8a48.png
    image.png

    Where <id> is automatically numbered, and we can use it to node query by looking up or operation
    eg for <id> node 1 = query


    1331259-215c95ae82de2471.png
    image.png
  • Skip Skip several nodes
    egskip 3 skips the first three nodes


    1331259-407226449618c299.png
    image.png
  • Merge operation
    EG Merge for node does not exist, the effect similar to create


    1331259-fd23f1b66cd0e28f.png
    image.png

    eg for existing points, only to find his role, and will not add nodes


    1331259-844707a9e1ab82d1.png
    image.png
  • In operation
    eg meet the selection criteria a given interval


    1331259-665b7176f1d765cb.png
    image.png
  • Fonts and display settings


    1331259-26c471dba9cb530f.png
    image.png

    You can choose the color size, caption section can choose to display the title

  • String Functions


    1331259-a40c4bb80767893b.png
    image.png
  • Aggregation function (similar to SQL, a statement in the return clause)
    the maximum and minimum self node id eg


    1331259-bcbc0d28ef736b1e.png
    image.png

    The number of piano eg hobby (statistics for specific attributes)


    1331259-7780fcecfe769bef.png
    image.png

    eglabel for the number of students (statistics for a particular label)
    1331259-c37830d60eedf1b3.png
    image.png
  • Relations function
    we first establish a small module, to facilitate subsequent operations


    1331259-63e33f1dea9c0cb2.png
    image.png

    eg to find the beginning of a relationship


    1331259-4f0a9b8c57a46d33.png
    image.png

    The same can also be found eg end
    1331259-bcb2e88ac2c2dc3c.png
    image.png

    eg when relations with specific attributes, we can find a specific relationship by limiting the attributes end and beginning
    1331259-d6b1856b6586d89c.png
    image.png

    eg while relations can query id, type, and some properties


    1331259-19e092ae5295f730.png
    image.png

    With a schema can look at the current situation index and constraint
    1331259-e8631dcf46cc3d9d.png
    image.png
  • Index
    eg create an index


    1331259-b3c2da23785b9cfd.png
    image.png

    eg see the index


    1331259-3c110d38c2ad3254.png
    image.png

    eg delete indexes
    1331259-21a25a1f32d19200.png
    image.png

    Index role: query optimization process
  • unique constraints
    eg create a unique constraint, attempt to insert a violation data, an error is detected


    1331259-0f18a36060e99401.png
    image.png

    1331259-ec4936d8c0e4a5a0.png
    image.png

For the third-party software Neo4j

  • Apoc: Awesome Procedures on Cypher (encapsulates some complex cypher write function)
  • Open source visual component library :( can be adjusted) according to their characteristics of the project
    D3.js: a JavaScript library based data processing document, can be achieved by operating data visualization HTML, SVG, CSS. We can introduce the page Neo4j end of JavaScript js library of API calls Neo4j to get the data, and then according to the organization D3.js API JSON data, and then render.
    vis.js, Sigma.js, Vivagraph.js, yWorks
  • Visualization scheme :( package easier to use, fully encapsulated, availability)
    Gephi, Keylines, Linkurio.us, Tom Sawyer FIG visualized
    (Neo4j Browser)
  • Neoclipse: help to better adjust, create, display database Neo4j
    a graph database utility designed to help you view and modify Neo4j databases when it comes to various properties and relationships, as well as to create new nodes and relationships.

Figure database instance modeled on practice (fraud)

  • Background: First-Party- Bank-Fraud Fraud real name / First Party Fraud
    nature: practical invent himself or herself or another person's identity, forged identity fraud, bank fraud specific to the first party to include credit card fraud, credit fraud, fraud overdrafts, unsecured credit fraud, etc., to defraud money from the bank through credit cards, loans and other tools, but a big problem there is no willingness to repay, which is facing the banks.
    Fraud ring normal modes of operation:
    a group of two or more people or a fraud ring composed of two, they share some of the information a legitimate contact, and then create multiple identities synthesized by different combinations of information. Fraud ring to use these identities to open accounts, normally used for some time, because the bank account of the lawful detected increased credit limit. Suddenly one day, everyone maximize the use of the credit line and then disappeared, leading to debt can not be recovered.
    Why use a database diagram:
    Graphs are the Designed to Express relatednessthey CAN Uncover Patterns 'apologetic' to the catch by Traditional Database.
    Operational drawing database: entity set different stages of analysis test
  • Simulation step
  1. 3 contacts and create three accounts
  2. Create an address to associate to a three contact address
  3. Create two telephone numbers, associating the three contacts for both phone numbers
  4. Create two SSN (community security account), were associated with three contacts
  5. Three each account or apply for a credit card without a mortgage
  6. An entity associated analysis: Find contact information shared by multiple legitimate account holders, and calculate the potential financial risks
    Below are the results achieved, the specific code attached to the end of the


    1331259-7552ecd04deb2c7f.png
    image.png

    Then analyzed for a number of entities associated with the model

  7. Analysis shared by multiple legitimate contact information of the account holder


    1331259-2f6935f14c7dfec3.png
    image.png

    1331259-91f66017254dbbb8.png
    image.png

    1331259-6d6b0d56606d4982.png
    image.png
  8. Calculation of possible financial risks


    1331259-629f7b5b086e094d.png
    image.png

    1331259-775f3e9a768cadd3.png
    image.png

    1331259-0b598aaab8aaa6fa.png
    image.png

    1331259-533e5a1e9f465fba.png
    image.png
create
(accountOwner1:AccountOwner{FirstName:"Sylvia",LastName:"Song",UniqueID:"SylviaSong"}),
(accountOwner2:AccountOwner{FirstName:"Angle",LastName:"Hao",UniqueID:"AngleHao"}),
(accountOwner3:AccountOwner{FirstName:"Jacky",LastName:"Song",UniqueID:"JackySong"}),
(address1:Address{Street:"123 NW1st Street",City:"Beijing"}),
(accountOwner1)-[:HAS_ADDRESS]->(address1),
(accountOwner2)-[:HAS_ADDRESS]->(address1),
(accountOwner3)-[:HAS_ADDRESS]->(address1),
(phoneNumber1:PhoneNumber{PhoneNumber:"111-111-11111"}),
(phoneNumber2:PhoneNumber{PhoneNumber:"222-222-22222"})
                                <-[:HAS_PHONENUMBER]-(accountOwner3),
(accountOwner1)-[:HAS_PHONENUMBER]->(phoneNumber1),
(accountOwner2)-[:HAS_PHONENUMBER]->(phoneNumber1),
(SSN1:SSN{SSN:"241-23-1234"}),
(accountOwner2)-[:HAS_SSN]->(SSN1),
(accountOwner3)-[:HAS_SSN]->(SSN1),
(SSN2:SSN{SSN:"241-23-5678"}),
(accountOwner1)-[:HAS_SSN]->(SSN2),
(creditCard1:CreditCard{AccountNumber:"1234567890123456",
                        Limit:5000,
                        Balance:1442.23,
                        ExpirarionDate:"01-20",
                        SecurityCode:"123"})<-[:HAS_CREDITCARD]-(accountOwner1),
(creditCard2:CreditCard{AccountNumber:"1234567890123456",
                        Limit:4000,
                        Balance:2345.56,
                        ExpirarionDate:"02-20",
                        SecurityCode:"456"})<-[:HAS_CREDITCARD]-(accountOwner2),
(bankAccount1:BankAccount{AccountNumber:"2345678901234567",
                          Balance:7054.43})<-[:HAS_BANKACCOUNT]-(accountOwner1),
(bankAccount2:BankAccount{AccountNumber:"3456789012345678",
                          Balance:4231.12})<-[:HAS_BANKACCOUNT]-(accountOwner2),
(bankAccount3:BankAccount{AccountNumber:"4567890123456789",
                          Balance:12345.45})<-[:HAS_BANKACCOUNT]-(accountOwner3),
(unsecuredLoan1:UnsecuredLoan{AccountNumber:"4567890123456789-0",
                              Balance:9045.53,
                              APR:.0541,
                             LoanAmount:12000.00})<-[:HAS_UNSECUREDLOAN]-(accountOwner2),
(unsecuredLoan2:UnsecuredLoan{AccountNumber:"5678901234567890-0",
                              Balance:16341.95,
                              APR:.0341,
                              LoanAmount:22000.00})<-[:HAS_UNSECUREDLOAN]-(accountOwner3)

Reproduced in: https: //www.jianshu.com/p/9e3c4892ab3e

Guess you like

Origin blog.csdn.net/weixin_33950035/article/details/91325132