Graph databases are great for web apps: instead of somehow having to map tables and rows to URLs, developers can simply 1-to-1 map objects in the GraphDB to URLs.
Here’s an example. Let’s say on your web page, you want to show a list of nodes related to some node ‘x’. For example, a social media friends list, or list of purchases, or bookmarks etc. Here is the JSP code:
<set:traverseIterate startObjectName="x" traversalSpecification="*" loopVar="y"> <set:iterateNoContent><p>Sorry, no neighbors.</p></set:iterateNoContent> <set:iterateHeader> <ul> </set:iterateHeader> <set:iterateContentRow> <li> <mesh:meshObjectLink meshObjectName="y"> <mesh:meshObject meshObjectName="y" /> </mesh:meshObjectLink> <li> </set:iterateContentRow> <set:iterateFooter> </ul> </set:iterateFooter> <set:traverseIterate>
If you look closely, you see that not only does it print the neighbor nodes in the graph, but also adds a hyperlink to them, so they can clicked on and examined. And if there are no neighbors, a message is printed saying so.
What if I don’t want any kind of neighbor, but only those related in some fashion, say business colleagues? Well, depends a bit on your model, but it’s usually as simple as replacing the first line of JSP above with something like this:
<set:traverseIterate startObjectName="x" traversalSpecification="com.example.MySubjectArea/Person_IsColleagueOf_Person-S" loopVar="y">
Notice that there is no other code that needs to be written, no object-relational mapping, no SQL syntax to get right, no handler code or other clumsy magic. Of course, you can have may of these statements on the same page, nested etc.
A great way of developing rich web pages really quickly.