Cypher Query Language

Cypher is a declarative graph query language that allows for expressive and efficient querying and updating of a property graph. 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] Cypher was largely an invention of Andrés Taylor while working for Neo4j, Inc.(formerly Neo Technology) in 2011.[2] Cypher was originally intended to be used with the graph database Neo4j, but was opened up through the openCypher project in October 2015.[3]

## Contents

* 1 Graph model
* 1.1 Type system
* 2 Syntax
* 3 Standardization
* 4 See also
* 5 References
* 6 External links

## Graph model

Cypher is based on the Property Graph Model, which in addition to the standard graph elements of nodes and edges (which are called relationships in Cypher) adds labels and properties as concepts. Nodes may have zero or more labels, while each relationship has exactly one relationship type.[4] Nodes and relationships also have zero or more properties, where a property is a key-value binding of a string key and some value from the Cypher type system.

### Type system

The Cypher type system includes nodes, relationships, paths, maps, lists, integers, floating-point numbers, booleans, and strings.[5]

## Syntax

Cypher contains a variety of clauses. Among the most common are: 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. WHERE is used to add additional constraints to patterns.[6] For example, the below query will return all movies where an actor named 'Nicole Kidman' has acted, and that were produced before a certain year (sent by parameter):

MATCH (nicole:Actor {name: 'Nicole Kidman'})-[:ACTED_IN]->(movie:Movie)
WHERE movie.year < $yearParameter
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. Nodes can only be deleted when they have no other relationships still existing. For example:[6]

MATCH (start:Content)-[:RELATED_CONTENT]->(content:Content)
WHERE content.source = 'user'
OPTIONAL MATCH (content)-[r]-()
DELETE r, content

## Standardization

With the openCypher project, an effort was started to standardize Cypher as the query language for graph processing. One part of this process is the First openCypher Implementers Meeting (oCIM), which was first announced in December 2016.[7][8]

## See also

* SPARQL, another declarative query language for querying graph data

## References

1. ↑ "Cypher Introduction". Neo Technology. http://neo4j.com/docs/developer-manual/current/cypher/#cypher-intro. Retrieved January 31, 2017.
2. ↑ "Cypher: An Evolving Query Language for Property Graphs". Proceedings of the 2018 International Conference on Management of Data. ACM. https://hal.archives-ouvertes.fr/hal-01803524/file/paper.pdf. Retrieved June 27, 2018.
3. ↑ "Meet openCypher: The SQL for Graphs - Neo4j Graph Database" (in en-US). Neo4j Graph Database. 2015-10-21. https://neo4j.com/blog/open-cypher-sql-for-graphs/.
4. ↑ "Property Graph Model" (in en). https://github.com/opencypher/openCypher/blob/master/docs/property-graph-model.adoc.
5. ↑ "Cypher Type System" (in en). https://github.com/opencypher/openCypher/blob/master/cip/1.accepted/CIP2015-09-16-public-type-system-type-annotation.adoc.
6. ↑ 6.0 6.1 "Neo4j 3.1.1 manual - MATCH clause". Neo Technology. http://neo4j.com/docs/developer-manual/current/cypher/clauses/match/. Retrieved January 31, 2017.
7. ↑ "openCypher Implementers Meeting · openCypher.org" (in en). http://www.opencypher.org/2017/01/17/ocim-announcement/.
8. ↑ "oCIM announcement on openCypher Google Groups". https://groups.google.com/forum/#!topic/opencypher/vCNM4UOXcTY.

## External links

* OpenCypher, an initiative by Neo4j, Inc. and others to extend the use of Cypher to other graph databases
* Meet openCypher: The SQL for Graphs

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Cypher_Query_Language&oldid=200942"