notes-computer-programming-graphDatabases

i don't know much about graph databases so take this all with a grain of salt.

What are graph databases good for, compared to relational databases?

Graph databases are good for questions like "Give me all people who have friends of enemies of friends who are their enemy?"

A friend gave me a practical example (i dont know enough about databases to know if the following is accurate, or if i misunderstood). Say you are a company with a bunch of log data from eg your website and you are analyzing your sales funnel. You are interested in being able to issue spur-of-the-moment queries of the form "out of the times where the user did A and then did B and then did C, how many of those times did that lead to a sale?". This sort of query is inefficient with relational databases because if you have one row for event, then in order to find instances where the same user (or IP address or whatever) issued event A then event B then event C (possibly with other events in between), you have to look thru all events (or maybe all events of type A) over and over again. One way to handle this is to shard the database by user. Another way is as follows:

In sum, graph databases are good for when you are querying for a multihop pattern between nodes. Relational dbs are good when you can break your query into one hop at a time.