Neo4j-cql-introduction
提供:Dev Guides
Neo4j CQL-はじめに
CQLはCypher Query Languageの略です。 Oracle Databaseにクエリ言語SQLがあるように、Neo4jにはクエリ言語としてCQLがあります。
Neo4j CQL
- Neo4jグラフデータベースのクエリ言語です。
- 宣言的なパターンマッチング言語です。
- SQLのような構文に従います。
- 構文は非常にシンプルで、人間が読める形式です。
Oracle SQLのように
- Neo4j CQLには、データベース操作を実行するコマンドがあります。
- Neo4j CQLは、非常に複雑なクエリを簡単に作成するために、WHERE、ORDER BYなどの多くの句をサポートしています。 *Neo4j CQLは、String、Aggregationなどの機能をサポートしています。 それらに加えて、いくつかの関係関数もサポートしています。
Neo4j CQL句
Neo4j* C ypher Q uery L *anguageの読み取り句は次のとおりです-
Sr.No | Read Clauses | Usage |
---|---|---|
1 | MATCH | This clause is used to search the data with a specified pattern. |
2 | OPTIONAL MATCH | This is the same as match, the only difference being it can use nulls in case of missing parts of the pattern. |
3 | WHERE | This clause id is used to add contents to the CQL queries. |
4 | START | This clause is used to find the starting points through the legacy indexes. |
5 | LOAD CSV | This clause is used to import data from CSV files. |
Neo4j* C ypher Q uery L *anguageの書き込み句は次のとおりです-
Sr.No | Write Clause | Usage |
---|---|---|
1 | CREATE | This clause is used to create nodes, relationships, and properties. |
2 | MERGE | This clause verifies whether the specified pattern exists in the graph. If not, it creates the pattern. |
3 | SET | This clause is used to update labels on nodes, properties on nodes and relationships. |
4 | DELETE | This clause is used to delete nodes and relationships or paths etc. from the graph. |
5 | REMOVE | This clause is used to remove properties and elements from nodes and relationships. |
6 | FOREACH | This class is used to update the data within a list. |
7 | CREATE UNIQUE | Using the clauses CREATE and MATCH, you can get a unique pattern by matching the existing pattern and creating the missing one. |
8 | Importing CSV files with Cypher | Using Load CSV you can import data from .csv files. |
Neo4j* C ypher Q uery L *anguageの一般的な条項は次のとおりです-
Sr.No | General Clauses | Usage |
---|---|---|
1 | RETURN | This clause is used to define what to include in the query result set. |
2 | ORDER BY | This clause is used to arrange the output of a query in order. It is used along with the clauses* RETURN or WITH*. |
3 | LIMIT | This clause is used to limit the rows in the result to a specific value. |
4 | SKIP | This clause is used to define from which row to start including the rows in the output. |
5 | WITH | This clause is used to chain the query parts together. |
6 | UNWIND | This clause is used to expand a list into a sequence of rows. |
7 | UNION | This clause is used to combine the result of multiple queries. |
8 | CALL | This clause is used to invoke a procedure deployed in the database. |
Neo4j CQL関数
以下は、頻繁に使用されるNeo4j CQL関数です-
Sr.No | CQL Functions | Usage |
---|---|---|
1 | String | They are used to work with String literals. |
2 | Aggregation | They are used to perform some aggregation operations on CQL Query results. |
3 | Relationship | They are used to get details of relationships such as startnode, endnode, etc. |
すべてのNeo4j CQLコマンド、句と関数の構文、使用方法、および例については、以降の章で詳しく説明します。
Neo4j CQLデータ型
これらのデータ型はJava言語に似ています。 ノードまたは関係のプロパティを定義するために使用されます。
Neo4j CQLは、次のデータ型をサポートしています-
Sr.No | CQL Data Type | Usage |
---|---|---|
1 | Boolean | It is used to represent Boolean literals: true, false. |
2 | byte | It is used to represent 8-bit integers. |
3 | short | It is used to represent 16-bit integers. |
4 | int | It is used to represent 32-bit integers. |
5 | long | It is used to represent 64-bit integers. |
6 | float | It is used to represent 32-bit floating-point numbers. |
7 | double | It is used to represent 64-bit floating-point numbers. |
8 | char | It is used to represent 16-bit characters. |
9 | String | It is used to represent Strings. |
CQL演算子
以下は、Neo4j Cypher Query言語でサポートされている演算子のリストです。
Sr.No | Type | Operators |
---|---|---|
1 | Mathematical | +, -, *,/, %, ^ |
2 | Comparison | +, <>, <, >, ⇐, >= |
3 | Boolean | AND, OR, XOR, NOT |
4 | String | + |
5 | List | +, IN, [X], [X…..Y] |
6 | Regular Expression | =- |
7 | String matching | STARTS WITH, ENDS WITH, CONSTRAINTS |
Neo4j CQLのブール演算子
Neo4jは、複数の条件をサポートするためにNeo4j CQL WHERE句で使用する次のブール演算子をサポートしています。
Sr.No | Boolean Operators | Description |
---|---|---|
1 | AND | It is a Neo4j CQL keyword to support AND operation. It is like SQL AND operator. |
2 | OR | It is a Neo4j CQL keyword to support OR operation. It is like SQL AND operator. |
3 | NOT | It is a Neo4j CQL keyword to support NOT operation. It is like SQL AND operator. |
4 | XOR | It is a Neo4j CQL keyword to support XOR operation. It is like SQL AND operator. |
Neo4j CQLの比較演算子
Neo4jは、条件をサポートするためにNeo4j CQL WHERE句で使用する次の比較演算子をサポートしています。
Sr.No | Boolean Operators | Description |
---|---|---|
1 | = | It is a Neo4j CQL "Equal To" operator. |
2 | < > | It is a Neo4j CQL "Not Equal To" operator. |
3 | < | It is a Neo4j CQL "Less Than" operator. |
4 | > | It is a Neo4j CQL "Greater Than" operator. |
5 | ⇐ | It is a Neo4j CQL "Less Than Or Equal To" operator. |
6 | > = | It is a Neo4j CQL "Greater Than Or Equal To" operator. |