0% found this document useful (0 votes)
12 views

Neo4j Basics to Advanced Full

Uploaded by

averyaustin295
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Neo4j Basics to Advanced Full

Uploaded by

averyaustin295
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Introduction to Neo4j: Basics to

Advanced
Understanding Graph Databases and
Cypher Queries
What is Neo4j?
• • Neo4j is a graph database designed for
storing and querying connected data.
• • Why Use Neo4j?
• - Fast queries for relationship-heavy data
• - Visual representation of data
• - Powerful graph algorithms
• • Examples of Use Cases:
• - Social Networks
• - Recommendation Engines
Core Concepts
• • Nodes: Entities (e.g., Person, Product)
• • Relationships: Connections between nodes
(e.g., KNOWS, LIKES)
• • Properties: Key-value pairs for nodes and
relationships
• • Labels: Categories for nodes
(e.g., :Person, :Product)
Graph Structure Example

• Nodes: Alice, Bob, Smartphone


• Relationships: Alice KNOWS Bob, Alice LIKES Smartphone
Installing Neo4j
• • Two Methods:
• 1. Download Neo4j Desktop:
https://neo4j.com/download/
• 2. Use Neo4j Sandbox:
https://sandbox.neo4j.com/
• • Follow step-by-step installation instructions.
Cypher Query Language (Basics)
• • CREATE: Adding nodes and relationships
• CREATE (a:Person {name: 'Alice', age: 30})
• CREATE (a)-[:KNOWS]->(b:Person {name:
'Bob', age: 25})
• • MATCH: Retrieving nodes and relationships
• MATCH (a:Person)-[:KNOWS]->(b)
• RETURN a.name, b.name
• • WHERE: Filtering queries
• MATCH (p:Person)
Hands-On Exercise (Data Modeling)
• • Use Case: Social Network
• • Nodes:
• - Person: Name, Age, City
• - Product: Name, Category, Price
• • Relationships:
• - KNOWS: Between Person nodes
• - LIKES: Between Person and Product nodes
Pre-Built Dataset
• // Create Person nodes
• CREATE (alice:Person {name: 'Alice', age: 30,
city: 'New York'})
• CREATE (bob:Person {name: 'Bob', age: 25,
city: 'Los Angeles'})
• ...
• // Create LIKES relationships
• CREATE (alice)-[:LIKES]->(phone)
• CREATE (bob)-[:LIKES]->(laptop)
Hands-On Queries
• • People who know Alice:
• MATCH (alice:Person {name: 'Alice'})-
[:KNOWS]->(friends)
• RETURN friends.name
• • Most liked product:
• MATCH (p:Person)-[:LIKES]->(product)
• RETURN product.name, COUNT(p) AS Likes
• ORDER BY Likes DESC LIMIT 1
• • People older than 30 who like products:
Advanced Cypher
• • Shortest Path Query:
• MATCH (start:Person {name: 'Alice'}),
(end:Person {name: 'Diana'})
• MATCH path = shortestPath((start)-
[:KNOWS*]-(end))
• RETURN path
• • Indexing for Performance:
• CREATE INDEX FOR (p:Person) ON (p.name)
• • Graph Algorithms: PageRank, Community
Q&A and Resources
• • Questions?
• • Useful Links:
• - Neo4j Documentation:
https://neo4j.com/docs/
• - Cypher Cheat Sheet:
https://neo4j.com/developer/cypher/

You might also like