neo4j
  1. neo4j-data-types

Data Types in Neo4j

Neo4j is a graph database system that supports a variety of datatypes. Understanding these datatypes is crucial for handling data within Neo4j.

Syntax

The following datatypes are supported by Neo4j:

  • Integer
  • Float
  • String
  • Boolean
  • Date
  • Time
  • DateTime
  • Duration
  • Point2D
  • Point3D
  • List
  • Map

Example

Consider the following example of a CYPHER query:

CREATE (p:Person {name: 'John', age: 30, isMarried: true, interests: ['reading', 'music']})

In this example, we are creating a Person node with name as string, age as integer, isMarried as boolean, and interests as a list.

Output

This query will create a node p with the following properties:

  • name: 'John'
  • age: 30
  • isMarried: true
  • interests: ['reading', 'music']

Explanation

In the above example, we can see that the CYPHER query creates a Person node with different data types as properties.

  • name property is of type String.
  • age property is of type Integer.
  • isMarried property is of type Boolean.
  • interests property is of type List.

Use

Understanding data types in Neo4j is essential to properly storing, retrieving, and querying data. When creating a node or a relationship in Neo4j, we must specify the data types for the properties we want to add.

Important Points

  • It is important to choose the correct data type when creating properties for nodes or relationships.
  • Neo4j's data types support a wide range of data and provide flexibility in handling data.
  • Values of properties can also be updated using the SET keyword to update an existing property.

Summary

Neo4j supports multiple data types to handle data flexibly. Choosing the proper data type for each property is essential in creating nodes and relationships within Neo4j. Understanding data types and their roles is a crucial part of using Neo4j effectively.

Published on: