Neo4J - Lab 1
In this lab session, we will explore Neo4j by setting up a Docker Neo4j instance using the provided command. We will cover the following:
- Launching a Docker Neo4j Container
- Accessing the Neo4j Browser Interface
- Creating a Sample Graph Database
- Running Cypher Queries
1. Lauch a Docker Neo4j Container
Steps
- Start up Docker
- Open your Terminal
-
Execute the following command
Info
This command creates a Docker container running the Neo4j image, maps ports 7474 and 7687 from the container to the host machine, and sets the initial authentication to "neo4j/admin123."
2. Access the Neo4j Browser Interface
Steps
- Open your web browser and navigate to http://localhost:7474
- Connect to the Neo4J using the following information:
- Connect URL:
neo4j://neo4j://localhost:7687
- Database - leave empty for default: leave it empty
- Authentication type:
Username / Password
- Username:
neo4j
- Password:
admin123
- Connect URL:
2. Create a Sample Graph Database
Steps
-
Create a simple graph database with nodes and relationships in the user interface
- paste the content into the top section on your screen with start with
neo4j$
-
hit the play button
CREATE (Alice:Person {name: "Alice", age: 30}) CREATE (Bob:Person {name: "Bob", age: 25}) CREATE (Charlie:Person {name: "Charlie", age: 35}) CREATE (Alice)-[:FRIEND]->(Bob) CREATE (Alice)-[:FRIEND]->(Charlie)
Expected results
- paste the content into the top section on your screen with start with
-
The following information in the log
4. Run Cypher Queries
Steps
-
Run the following Cypher query into the Neo4J interface
-
Click on the Graph icon in the left page
This query retrieves Alice and her friends.
Expected results
-
The following relationship between
Alice
and its friendserDiagram Charlie ||--o{ Alice : friend Bob ||--o{ Alice : friend