storage engine which supports a graph data model backed by native graph persistence, with access and query methods for the graph primitives to make querying the stored data pleasant and performant.”
where rows contain columns which can contain further columns. » Fast writes. » Some relation support primarily based on location of data (making the layout of the data the key).
PersonFriend ON Person.person = PersonFriend.person WHERE Person.person = 'Bob‘ Alice’s friends-of-friends SELECT pf1.person as PERSON, pf3.person as FRIEND_OF_FRIEND FROM PersonFriend pf1 INNER JOIN Person ON pf1.person = Person.person INNER JOIN PersonFriend pf2 ON pf1.friend = pf2.person INNER JOIN PersonFriend pf3 ON pf2.friend = pf3.person WHERE pf1.person = 'Alice' AND pf3.person <> 'Alice'
Neo4j Execution Time (S) Records Returned 2 0.016 0.01 ~2500 3 30.267 0.168 ~110,000 4 1543.505 1.359 ~600, 000 5 Unfinished 2.132 ~800, 000 * For a social network containing 1,000,000 people each with approximately 50 friends.
schema » Tables have more than a couple of foreign keys » You find yourself using more than one alias for the same table in a single query » You use more than 4 or 5 joins in a single query
(mary)-[:PURCHASED]->(orders)-[:CONTAINS]->(detail)-[:SPECIFIES]->(inv) RETURN inv.SKU, inv.Description, inv.Price, detail.Quantity SELECT inv.SKU, inv.Description, inv.Price, od.Quantity FROM Inventory inv join orderdetail od on od.InventoryId = inv.inventoryid join [order] o on o.orderid = od.orderid join customer c on c.customerId = o.customerid WHERE c.FirstName = 'Mary'
= "Mary") MATCH (mary)-[:PURCHASED]->(orders)-[:CONTAINS]->(detail)-[:SPECIFIES]->(inv) WHERE inv.SKU = "BR549" RETURN SUM(detail.Quantity) SELECT sum(od.Quantity) FROM Inventory inv join orderdetail od on od.InventoryId = inv.inventoryid join [order] o on o.orderid = od.orderid join customer c on c.customerId = o.customerid WHERE c.FirstName = 'Mary' AND inv.SKU = 'BR549'