Zum Inhalt springen

Cypher (Abfragesprache)

aus Wikipedia, der freien Enzyklopädie
Dies ist eine alte Version dieser Seite, zuletzt bearbeitet am 20. Juli 2015 um 07:44 Uhr durch Cedar101 (Diskussion | Beiträge) (Syntax: lang="cypher"). Sie kann sich erheblich von der aktuellen Version unterscheiden.

Cypher is a declarative graph query language for the graph database, Neo4j that allows for expressive and efficient querying and updating of the graph store. Cypher is a relatively simple but still very powerful language. Very complicated database queries can easily be expressed through Cypher. This allows users to focus on their domain instead of getting lost in database access.[1]

Syntax

Cypher contains a variety of clauses, some of the most common of which include MATCH and WHERE. These functions are slightly different than in SQL. MATCH is used for describing the structure of the pattern searched for, primarily based on relationships, and WHERE is used to add additional constraints to patterns. For example:[2]

    MATCH (charlie:Person { name:'Charlie Sheen' })-[:ACTED_IN]-(movie:Movie)
    RETURN movie

Cypher additionally contains clauses for writing, updating, and deleting data. CREATE and DELETE are used to create and delete nodes and relationships. SET and REMOVE are used to set values to properties and add labels on nodes. It should be noted that nodes can only be deleted when they have no other relationships still existing. For example:[2]

    START x = node(123)
    MATCH x-[r?:RELATED_CONTENT]->content
    WHERE content.source='user'
    WITH content
    MATCH content-[r1?]-()
    DELETE r1, content

References

Vorlage:Reflist

See Also

Gremlin Programming Language, another API for querying graph data

  1. Cypher Introduction. Abgerufen am 19. Januar 2014.
  2. a b 10.1. Match - - The Neo4j Manual v2.1.2. Abgerufen am 18. Juni 2014.