Skip to content

Writing Queries for Neo4j

Neo4j Logo
Image source: Wikimedia Commons

Instructions

Create a file named neo4j-notes.md for taking notes during the lab. Submit your notes to Gradescope.

Part 1: Explore Neo4j Website

  1. Write your name at the top of your neo4j-notes.md file, for example:
    Name: Alan Turing
    
  2. Spend a minute or two reading through the Why Graph Databases? page.
  3. Open the Get Started with Neo4j documentation and skim the sections:
    • What is Neo4j?
    • What is a graph database?
    • What is Cypher?
  4. Write a short paragraph in your notes summarizing what you learned so far.
    • Or, if you would rather, you may write bullet list notes instead.

Part 2: Create Neo4j Sandbox

  1. Open the Neo4j Sandbox and click "Launch the Free Sandbox" button. Then click "Sign up" or log in with Google, X, or LinkedIn.
  2. Select a dataset of your choice—there are 25 to choose from! Click the "Create and Download credentials" button (bottom left) to create the sandbox instance.
    • A file named "… Sandbox Credentials.txt" (where "…" is your dataset name) will automatically download. This file contains the URI, username, and password for your database.
  3. Copy and paste your Sandbox Credentials into your notes file.

Part 3: Neo4j Sandbox Queries

  1. Start the instance and figure out how to log in to the database (either single sign-on or username/password).
  2. After logging in, the "Guides" panel (on the left) should open. Work through the tutorial for the remaining time.
    • You might find the Cypher Cheat Sheet useful for explaining and writing your own queries.
    • Run CALL db.schema.visualization() to see a summary of nodes and relationships.
  3. Save the more interesting queries you write, along with your own comments explaining them, in your notes file.
    • You must put your queries in code blocks, for example:
      Show the name and price of products that start with "C" and cost more than \$100.
      ``` cypher
      MATCH (p:Product)
      WHERE p.productName STARTS WITH "C" AND p.unitPrice > 100
      RETURN p.productName, p.unitPrice;
      ```
      
    • To enable syntax highlighting for Cypher, install the Neo4j for VS Code extension.

Submission

Upload your neo4j-notes.md file to Gradescope. Your file must have at least 1500 chars, at least 50 lines, and at least 5 code blocks (``` cypher).