Techfin.in reports on using Neo4j and Cypher for delivering news via a newsfeed or timeline. Implementation of newsfeed or timeline feature became a must requirement for every social application. Achieving the same result through traditional relational databases would have been cumbersome as well as inefficient due to number of joins in SQL query. Would post an another article on why graph databases especially NEO4J is an apt choice for social application. For now, this post would directly jump into the implementation of simple newsfeed feature using powerful graph database NEO4J. (This article assumes that reader already understands basic concepts of graph databases representation, Neo4j and Cypher query language). Neo4j Documentation has already given us the data model to represent social network in graph database and queries to retrieve data. Instead of repeating the whole story, this post would compliment the existing doc by giving cypher queries to create and retrieve data for below data model. Data model (or E-R diagram in terms of relational DB terminology):
The data model for a social network is pretty simple: Persons with names and StatusUpdates with timestamped text. These entities are then connected by specific relationships. 
  • Person
    • friend: relates two distinct Person instances (no self-reference)
    • status: connects to the most recent StatusUpdate
  • StatusUpdate
    • next: points to the next StatusUpdate in the chain, which was posted before the current one
(Source: Neo4j Documentation) Read the full article.
 

Keywords: