How Do I Use A Graph DB?

So is this thing web scale?

We primarily use Neo4j at Graph Story, so we'll talk specifically about getting up to speed with that. There are, of course, other graph DBs out there, and some of these will apply to them as well.

  1. Learn Cypher

    Cypher is a query language similar to SQL that was created for use with Neo4j. It's an open standard, now, so we may see it available with other graph systems in the future. The appeal of Cypher is in it's conceptual similarity to SQL, and in using an "ASCII art"-style approach to describing relationships.

    Here's a straightforward Cypher example:

    MATCH (n1:Label1)-[rel:TYPE]->(n2:Label2)
    WHERE rel.property > {value}
    RETURN rel.property, type(rel)

    You can check out the Cypher intro at Neo's web site, but a great way to get started quickly is to visit the WebUI of any Neo4j install. A couple nice tutorials are built-in that step you through using Cypher against built-in data sets.

    The WebUI from Neo4j 3.0.2
  2. Take on a project

    A lot of us learn best by making something. If you havent already been tasked with one, a side project can be a great way to learn about graphs in a fun way. Ed Finkler, one of our team members, wrote a blog post about starting a graph side project.

  3. Learn some things about data modeling for graphs

    Best practices for how to structure your graph are, not surprisingly, different from a relational database. Without getting too detailed here, there's a nice intro to the basics on Neo's web site.

  4. learn how to write performant queries

    One of the most common problems we see are poorly-written queries that hobble the database – something that is significantly easier to do with Neo4j than, say, MySQL or PostgreSQL. You'll want to learn and use the EXPLAIN and PROFILE keywords in Cypher to break down the execution plan for a query that seems slow, but the most common issues we see are:

    1. Not using unique constraints and indexes on node properties
    2. Specify labels in your query to only scan a subset of nodes
    3. Returning entire nodes or relationships, instead of just the data needed

    The section on Query Tuning in the Neo4j developer docs is a must-read on this topic. We also recommend the Tuning Cypher Queries talk by Petra Selmer and Mark Needham from GraphConnect 2015.

  5. Find a library for your language

    There are Neo4j drivers and libraries for most popular programming languages, and we list many of them on our Docs page (login required). These vary from low-level libs to send handwritten Cypher queries to complex OGMs (Object-Graph Mappers).

  6. Ask us questions!

    We're proud at Graph Story to have the best support in the industry. We want to help you be successful incorporating the power of graphs into your processes. We are happy to answer any questions you have using our support chat (see the bottom-right of the window), or email us at support@graphstory.com. If you need more extended help, our professional services team is available to help you build graph-powered applications and advise on incorporating graphs into your existing stack.