Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
  1. Home
  2. /
  3. Learn
  4. /
  5. Cypher

Learn Cypher - 10 Code Examples & CST Typing Practice Test

Cypher is Neo4j’s declarative graph query language designed for creating, querying, and manipulating graph data structures. It uses ASCII-art-like pattern matching to express complex graph relationships intuitively.

View all 10 Cypher code examples →
Basic Cypher QueriesAdvanced Cypher FilteringNeo4j AggregationNeo4j Path MatchingNeo4j Create With PropertiesNeo4j Relationship PropertiesNeo4j Delete NodesNeo4j IndexesNeo4j ConstraintsNeo4j Full-Text Search

Learn CYPHER with Real Code Examples

Updated Nov 18, 2025

Explain

Cypher excels at querying highly connected data using patterns instead of joins.

Ideal for graph use cases like recommendations, social networks, fraud detection, and knowledge graphs.

Supports MATCH patterns, variable-length traversals, shortest path queries, constraints, and graph algorithms.

Core Features

MATCH, CREATE, MERGE, DELETE

Graph pattern matching

Property filtering

Path traversals

Aggregation and ordering

Constraints (UNIQUE, EXISTS)

Basic Concepts Overview

Nodes, Relationships, Properties

Labels and relationship types

MATCH patterns

CREATE, MERGE for graph updates

Constraints (UNIQUE, EXISTS)

Pathfinding queries

Project Structure

Node labels & relationship types

Indexes and constraints

APOC utilities

Stored procedures and triggers

Graph algorithms pipelines

Building Workflow

Model graph entities as nodes and relationships

Create constraints for uniqueness

Insert nodes/edges with CREATE/MERGE

Query using MATCH and filters

Optimize with indexes and profiling

Difficulty Use Cases

Beginner: MATCH, CREATE, simple traversals

Intermediate: MERGE, variable-length paths, constraints

Advanced: graph algorithms, APOC utilities

Expert: optimization, clustering, multi-graph architectures

Comparisons

More expressive than SQL for graph queries

Simpler than Gremlin for beginners

More user-friendly than SPARQL for non-semantic graphs

Better tooling and ecosystem for visualization

Versioning Timeline

2011 - Initial Cypher release by Neo4j

2015 - openCypher initiative introduced

2018 - major performance upgrades

2020-2025 - GDS integration, improved pattern matching

Glossary

Node: Entity in graph

Relationship: Directed edge

Property: Key-value attribute

Label: Node type

Pattern: ASCII-art graph structure

Installation Setup

Install Neo4j Desktop or Neo4j Community/Enterprise

Enable Bolt protocol

Configure memory and cache settings

Create constraints and indexes

Use Cypher Shell or Neo4j Browser

Environment Setup

Install Neo4j

Configure memory & clustering

Install APOC/GDS

Connect via Browser or Shell

Config Files

neo4j.conf

APOC config

Driver configuration (bolt settings)

GDS procedure configs

Cli Commands

cypher-shell

:schema commands

:PROFILE and :EXPLAIN

MATCH, CREATE, MERGE statements

Internationalization

UTF-8 support

No locale-specific constraints

Works with multilingual datasets

Full-text search w/ analyzers

Accessibility

Readable ASCII-art syntax

Self-explanatory patterns

Schema-optional modeling

Rich documentation & examples

Ui Styling

Visualization via Neo4j Browser

Custom nodes/edges in Bloom

APIs for front-end graph visualization

GraphQL integration for UI apps

State Management

Nodes hold properties

Relationships store direction & metadata

Transactions handle atomic operations

APOC/GDS manage advanced states

Data Management

CRUD using Cypher

Batch imports

Index creation

Graph projections for analytics

Architecture

Cypher queries run on Neo4j’s graph engine

Index-based lookups for efficient node scans

Native graph storage and traversal engine

APOC and GDS extend Cypher’s capabilities

Client access via Bolt protocol

Rendering Model

Parser interprets Cypher query

Planner selects optimal traversal plan

Graph engine performs index or label scan

Traversals executed and returned

Architectural Patterns

Native graph storage

Property graph model

Pattern-matching semantics

Multi-hop relational traversal

Real World Architectures

Fraud graph systems

Social network graph pipelines

Recommendation microservices

Knowledge graph backends

Design Principles

Intuitive pattern representation

Declarative graph processing

High-performance traversal engine

Schema-optional graph modeling

Scalability Guide

Use indexes for lookup-heavy queries

Cluster with Neo4j Enterprise

Optimize patterns to avoid full scans

Use GDS for heavy analytics

Migration Guide

Convert relational JOINs into relationships

Migrate tables -> nodes and relationships

Optimize with constraints/indexes

Rewrite SQL logic using MATCH patterns

Performance Notes

Use indexes for label/property lookups

Avoid unnecessary variable-length traversals

Use relationship direction for speed

Avoid Cartesian products unless intended

Security Notes

Enable role-based authentication (Neo4j Enterprise)

Use parameterized queries to avoid injection

Restrict access via Bolt protocol

Monitor database permissions and logs

Monitoring Analytics

Query logs & Bolt monitoring

APOC metrics

Neo4j Ops Manager

Profiling and slow query inspection

Code Quality

Avoid deep nesting

Use MERGE only when needed

Add constraints early

Use parameterized queries

Practical Examples

Find friends-of-friends relationships

Create user and purchase graph

Shortest path between two nodes

PageRank on user graph

Detect fraud rings via pattern match

Troubleshooting

Fix missing index warnings

Resolve MERGE creating duplicates

Optimize slow queries using PROFILE

Avoid Cartesian products in MATCH

Testing Guide

Unit test using neo4j-harness

Test constraints and MERGE behavior

Use PROFILE for performance validation

Mock drivers for app-layer testing

Deployment Options

Single-node Neo4j Community

Neo4j Enterprise cluster

Neo4j AuraDB cloud

Docker/Kubernetes deployment

Tools Ecosystem

Neo4j Browser

Neo4j Desktop

Cypher Shell

Neo4j Bloom

APOC and Graph Data Science (GDS)

Integrations

Node.js (neo4j-driver)

Java (official driver)

Python (py2neo, neo4j-driver)

GraphQL integration

Kafka Connect for streaming

Productivity Tips

Use PROFILE for optimization

Leverage APOC utilities

Index entry nodes properly

Pre-create graph projections for GDS

Challenges

Model a social graph with recommendations

Build fraud detection using multi-hop paths

Implement shortest path routing

Create product similarity graph via shared interactions

Learning Path

Learn graph modeling basics

Understand nodes, relationships, properties

Learn MATCH, CREATE, MERGE

Master pathfinding and graph patterns

Learn optimization and indexing

Skill Improvement Plan

Week 1: Cypher basics

Week 2: MERGE, constraints, pattern matching

Week 3: Graph algorithms

Week 4: Cluster scaling, indexing, optimization

Interview Questions

Explain how Cypher MATCH works.

Difference between CREATE and MERGE?

What causes Cartesian products?

How do you optimize Cypher queries?

What is a variable-length path?

Cheat Sheet

MATCH (n)-[:TYPE]->(m)

CREATE vs MERGE

Shortest path: shortestPath()

Filtering with WHERE

Relationship direction -> performance boost

Books

Learning Neo4j

Graph Databases (O’Reilly)

Hands-On Graph Analytics with Neo4j

Tutorials

Cypher Basics

Graph Modeling for Beginners

Advanced Neo4j Graph Algorithms

Official Docs

Neo4j Cypher Reference

openCypher Documentation

APOC and GDS Manuals

Community Links

Neo4j Community

StackOverflow Cypher tag

Neo4j Discord/Slack

Community Support

Neo4j community forums

StackOverflow cypher tag

Neo4j Discord groups

Neo4j Developer Blog

Monetization

Graph engineering roles

Consulting for fraud/recommendation systems

Building knowledge graph solutions

Graph analytics for enterprises

Future Roadmap

More openCypher standardization

Faster traversal engines

Improved clustering performance

Expanded GDS analytics support

When Not To Use

Pure tabular data with few relationships

OLAP warehouse-style reporting

Highly write-heavy workloads without batching

Datasets requiring strict ACID with cross-shard transactions

Final Summary

Cypher is Neo4j’s powerful, intuitive graph query language.

Ideal for connection-heavy data and real-time graph analytics.

Used in fraud detection, recommendations, and knowledge graphs.

Supports pattern matching, graph manipulation, and graph algorithms.

Faq

Is Cypher like SQL?

Cypher is declarative like SQL but optimized for graph relationships.

Does Cypher support JOINs?

Relationships replace JOINs in Cypher queries.

Is Cypher hard to learn?

No - very intuitive due to pattern syntax.

Why use Cypher?

To analyze connected data with powerful pattern queries.

Code Sample Descriptions

1

Basic Cypher Queries

CREATE (a:Person {name: "Alice"})
CREATE (b:Person {name: "Bob"})
CREATE (a)-[:FRIEND]->(b);

MATCH (p:Person)-[:FRIEND]->(f)
RETURN p.name, f.name;

Creating nodes and relationships, then querying them in Neo4j using Cypher.

Let’s Try →
2

Advanced Cypher Filtering

MATCH (p:Person)-[:FRIEND*1..2]->(f)
WHERE p.name = "Alice"
RETURN f.name;

Using WHERE clauses and relationship depth in Neo4j queries.

Let’s Try →
3

Neo4j Aggregation

MATCH (p:Person)-[:FRIEND]->(f)
RETURN p.name, COUNT(f) AS friend_count
ORDER BY friend_count DESC;

Counting friends per user with Cypher aggregation.

Let’s Try →
4

Neo4j Path Matching

MATCH p = (a:Person {name:"Alice"})-[:FRIEND*2]->(b:Person)
RETURN p;

Querying all paths of a certain length between nodes.

Let’s Try →
5

Neo4j Create With Properties

CREATE (c:Company {
    name: "TechCorp",
    founded: 2020,
    location: "NYC"
});

Creating a node with multiple properties in Cypher.

Let’s Try →
6

Neo4j Relationship Properties

MATCH (a:Person {name: "Alice"}), (b:Person {name: "Bob"})
CREATE (a)-[:WORKED_WITH {since: 2021}]->(b);

Adding properties to relationships in Neo4j.

Let’s Try →
7

Neo4j Delete Nodes

MATCH (p:Person {name: "Alice"})
DETACH DELETE p;

Deleting nodes and relationships in Neo4j.

Let’s Try →
8

Neo4j Indexes

CREATE INDEX person_name_index FOR (p:Person) ON (p.name);

Creating an index on node properties in Neo4j.

Let’s Try →
9

Neo4j Constraints

CREATE CONSTRAINT unique_email IF NOT EXISTS
FOR (p:Person)
REQUIRE p.email IS UNIQUE;

Adding uniqueness constraint to ensure unique property values.

Let’s Try →
10

Neo4j Full-Text Search

CALL db.index.fulltext.createNodeIndex("personIndex", ["Person"], ["name","email"]);

CALL db.index.fulltext.queryNodes("personIndex", "Alice")
YIELD node, score
RETURN node.name, score;

Using full-text indexes to search across multiple properties.

Let’s Try →

Frequently Asked Questions about Cypher

What is Cypher?

Cypher is Neo4j’s declarative graph query language designed for creating, querying, and manipulating graph data structures. It uses ASCII-art-like pattern matching to express complex graph relationships intuitively.

What are the primary use cases for Cypher?

Graph traversal and pathfinding. Recommendation systems. Social network analysis. Fraud detection and link analysis. Knowledge graphs and semantic search. Network and IT infrastructure mapping

What are the strengths of Cypher?

Intuitive pattern-based syntax. High performance for relationship-heavy queries. Strong ecosystem (APOC, GDS library). Excellent visualization in Neo4j Browser. Supports complex graph analytics

What are the limitations of Cypher?

Not ideal for massive tabular datasets. Requires graph modeling expertise. Performance depends on proper indexing. Limited JOIN-like operations outside graph context

How can I practice Cypher typing speed?

CodeSpeedTest offers 10+ real Cypher code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.

Learn Other Programming Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlGremlinPartiqlHaskellElixirFsharpJuliaView all languages →
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.