title: How to Model Real-World Relationships in a Graph Database (like Neo4j)?
body: <p>I have a general question about modeling in a graph database that I just can't seem to wrap my head around.</p>
  
  <p>How do you model this type of relationship: "Newton invented Calculus"?</p>
  
  <p>In a <a href="http://docs.neo4j.org/chunked/snapshot/graphdb-neo4j-relationships.html" rel="noreferrer">simple graph</a>, you could model it like this:</p>
  
  <pre><code>Newton (node) -&gt; invented (relationship) -&gt; Calculus (node)
  </code></pre>
  
  <p>...so you'd have a bunch of "invented" graph relationships as you added more people and inventions.</p>
  
  <p>The problem is, you start needing to add a bunch of properties to the relationship:</p>
  
  <ul>
  <li>invention_date</li>
  <li>influential_concepts</li>
  <li>influential_people</li>
  <li>books_inventor_wrote</li>
  </ul>
  
  <p>...and you'll want to start creating relationships between those properties and other nodes, such as:</p>
  
  <ul>
  <li>influential_people: relationship to person nodes</li>
  <li>books_inventor_wrote: relationship to book nodes</li>
  </ul>
  
  <p>So now it seems like the "real-world relationships" ("invented") should actually be a node in the graph, and the graph should look like this:</p>
  
  <pre><code>Newton (node) -&gt; (relationship) -&gt; Invention of Calculus (node) -&gt; (relationship) -&gt; Calculus (node)
  </code></pre>
  
  <p>And to complicate things more, other people are also participated in the invention of Calculus, so the graph now becomes something like:</p>
  
  <pre><code>Newton (node) -&gt; 
    (relationship) -&gt; 
      Newton's Calculus Invention (node) -&gt; 
        (relationship) -&gt; 
          Invention of Calculus (node) -&gt; 
            (relationship) -&gt; 
              Calculus (node)
  Leibniz (node) -&gt; 
    (relationship) -&gt; 
      Leibniz's Calculus Invention (node) -&gt; 
        (relationship) -&gt; 
          Invention of Calculus (node) -&gt; 
            (relationship) -&gt; 
              Calculus (node)
  </code></pre>
  
  <p>So I ask the question because it seems like <em>you don't want to set properties on the actual graph database "relationship" objects</em>, because you may want to at some point treat them as nodes in the graph.</p>
  
  <p>Is this correct?</p>
  
  <p>I have been studying the <a href="http://www.freebase.com/docs/mql/ch02.html" rel="noreferrer">Freebase Metaweb Architecture</a>, and they seem to be treating everything as a node.  For example, Freebase has the idea of a <a href="http://wiki.freebase.com/wiki/CVT/Mediator_CVT_proposal" rel="noreferrer">Mediator/CVT</a>, where you can create a "Performance" node that links an "Actor" node to a "Film" node, like here: <a href="http://www.freebase.com/edit/topic/en/the_last_samurai" rel="noreferrer">http://www.freebase.com/edit/topic/en/the_last_samurai</a>.  Not quite sure if this is the same issue though.</p>
  
  <p>What are some guiding principles you use to figure out if the "real-world relationship" should actually be a graph node rather than a graph relationship?</p>
  
  <p>If there are any good books on this topic I would love to know.  Thanks!</p>