3 Your first steps with Cypher query language

 

This chapter covers

  • Introducing the Cypher query language syntax
  • Creating nodes and relationships with Cypher
  • Matching and retrieving data from the database
  • Removing properties and deleting nodes and relationships
  • Best practices for importing a CSV into a graph database

So far, you have learned a bit of graph theory and how to approach the labeled-property graph modeling process. Now, you will begin to learn how to perform network analysis through practical use cases. To follow the examples in this book, you need to set up a Neo4j development environment. If you need some help getting started with the setup, see the appendix.

This chapter will introduce Cypher query language clauses and best practices for importing data into a graph database. First, I will do a quick recap of using Cypher query language syntax to represent networks in a textual format. If you are already familiar with the Cypher query syntax, you can skip most of the chapter and just import the data as shown in the last section. Remember from the previous chapter that the Cypher syntax uses parentheses to encapsulate a representation of a node. A quick reminder how to describe a node with Cypher syntax is shown in figure 3.1.

Figure 3.1 Cypher query language syntax to represent a node with its label and properties
03-01

3.1 Cypher query language clauses

3.1.1 CREATE clause

3.1.2 MATCH clause

3.1.3 WITH clause

3.1.4 SET clause

3.1.5 REMOVE clause

3.1.6 DELETE clause

3.1.7 MERGE clause

3.2 Importing CSV files with Cypher

3.2.1 Clean up the database

3.2.2 Twitter graph model

3.2.3 Unique constraints