Cypher (query language)
Cypher is a declarative query language for graphs that enables expressive and efficient queries and updates on so-called property graphs. Cypher is a relatively simple, yet powerful language. Even very complicated database queries can be formulated easily with the help of Cypher. This allows users to concentrate on their real goal instead of getting lost in the database.
Cypher was mainly an invention of Andrés Taylor, which he made in 2011 while working for Neo4j, Inc. (formerly "Neo Technology"). Cypher was originally intended to be used with the Neo4j graph database , but was brought to the open source world by the openCypher project in October 2015 .
Graph model
Cypher is based on the property graph model, which in addition to the standard graph elements node (English "nodes") and edges (English "edges"; which in Cypher relationships - English "relationships" - hot) labels (English " labels ") and properties (English" properties ") as concepts. Nodes can have zero or many tags, while relationships have exactly one relationship type. Nodes and relationships also have no or many properties in which properties consist of a key and a value and the key consisting of a character string to a value from the type system of Bind Cypher.
Type system
The type system of Cypher contains nodes, relationships (edges), paths, maps, lists, integers, floating point numbers ( "floating point numbers"), logical values ("booleans") and strings.
syntax
Cypher contains a variety of clauses. The most common are “MATCH” and “WHERE”. These have a slightly different functionality from what is known from the database query language SQL . MATCH is used to describe the structure of the sought-after pattern, which is primarily based on relationships. WHERE is used to define additional conditions ("constraints") for the patterns. For example, the following query will return all films in which an actress 'Nicole Kidman' starred and which were produced a certain year ago (given by a parameter) as an answer:
MATCH (nicole:Actor {name: 'Nicole Kidman'})-[:ACTED_IN]->(movie:Movie)
WHERE movie.year < $yearParameter
RETURN movie
In addition, Cypher contains clauses for writing, updating and deleting data. "CREATE" and "DELETE" are used to create and delete nodes and relationships, respectively. "SET" and "REMOVE" are used to set and remove values of properties and labels from nodes. Nodes can only be deleted if they have no relationships (to other nodes). An example:
MATCH (start:Content)-[:RELATED_CONTENT]->(content:Content)
WHERE content.source = 'user'
OPTIONAL MATCH (content)-[r]-()
DELETE r, content
standardization
With the openCypher project, an attempt was made to establish Cypher as the standard query language for graph processing. Part of the process was the First openCypher Implementers Meeting (oCIM), which was first announced in December 2016.
See also
- SPARQL , another declarative query language for graph data
- Graph database
Web links
- OpenCypher , an initiative by Neo4j, Inc. and others to extend the use of Cypher to other graph databases
- Meet open cypher: The SQL for Graphs (English)
Individual evidence
- ↑ The property graph model. In: Databases Online Lexicon . TH Köln, Campus Gummersbach, accessed on February 6, 2019 .
- ^ Cypher Introduction . Neo Technology. Retrieved January 31, 2017.
- ^ Cypher: An Evolving Query Language for Property Graphs . Proceedings of the 2018 International Conference on Management of Data. ACM. Retrieved June 27, 2018.
- ↑ Meet openCypher: The SQL for Graphs - Neo4j Graph Database . In: Neo4j Graph Database , October 21, 2015. Retrieved January 31, 2017.
- ^ Property Graph Model . GitHub.
- ^ Cypher Type System . GitHub.
- ↑ a b Neo4j 3.1.1 manual - MATCH clause . Neo Technology. Retrieved January 31, 2017.
- ↑ openCypher Implementers Meeting · openCypher.org . opencypher.org. Archived from the original on January 28, 2017. Retrieved January 31, 2017.
- ↑ oCIM announcement on openCypher Google Groups . groups.google.com.