Database Reference
In-Depth Information
Patterns and pattern matching
Patterns and pattern matching is one of the important components for extracting data from
the graph databases. Let's first talk about the definition of patterns and pattern matching
and then we will see how these are implemented in the context of Neo4j:
Pattern : In simple language and to make it even simpler to understand, a pattern is
an occurrence of sequence of characters/numbers, word or group of words, literals
that need to be found in a given dataset.
Pattern matching : The process or algorithm used for finding or matching a pat-
tern or sequence of patterns against a given dataset or data structure is called pat-
tern matching. In other words, pattern matching consists of specifying patterns to
which some data should conform and then checking to see if it does and decon-
structing the data according to those patterns. Pattern matching should not be con-
fused with pattern recognition, in which the match usually has to be exact.
There are well-known graph query languages which implement pattern matching and can
be used to query graphs, but they are tedious and involve a lot of work in maintenance/
modifications and enhancements. A few of the well-known graph query languages include:
SPARQL : http://en.wikipedia.org/wiki/SPARQL
GREMLIN : http://gremlin.tinkerpop.com/
Metaweb Query Language ( MQL ): https://developers.google.com/freebase/v1/
mql-overview
They also failed to meet one or more of the primary goals of the query language for the
Neo4j database which are as follows:
• Declarative
• ASCII art pattern
• External DSL
• SQL familiarity
• Closures
Considering all the preceding goals, Neo4j implemented the concepts of patterns and pat-
tern matching and provided a new declarative graph query language, Cypher, as a query
language for the Neo4j graph database. Cypher is specifically designed to be a humane
query language, which is focused on making things simpler for developers. Another benefit
of being a declarative language is that it focuses on "What to retrieve?" and not "How to re-
trieve?", which is in contrast to the other imperative languages such as Java and Gremlin.
Search WWH ::




Custom Search