In the latest post to the SitePoint PHP blog Christophe Willensen shows you how to use PHP and the Neo4j graph database to make efficient user timelines in your application. In this case, "timeline" should be thought of as something like a Twitter or Facebook status update feed.
Any social application you encounter nowadays features a timeline, showing statuses of your friends or followers generally in a descending order of time. Implementing such a feature has never been easy with common SQL or NoSQL databases. Complexity of queries, performance impacts increasing with the number of friends/followers and difficulties to evolve your social model are points that graph databases are eliminating. In this tutorial, we're going to extend the demo application used by the two introduction articles about Neo4j and PHP.
He starts off with a look at how to model the timeline in the graph database, showing different methods to create the relationships: one a direct user-to-post and the other via a linked list. He goes through the initial setup of the codebase and the sample dataset to populate the Neo4j database. He then includes code samples showing how to get the latest feed items for a user and displaying the results in a simple template (Twig-based). He also shows how to get the latest posts for the timeline and how to add a new post.