An Effective Way to Create Relationships with a NoSQL Database

I'm currently trying to implement Tumblr-like user interactions such as reblog, follow, followers, commenting, blog posts of the people I'm currently visiting. There is also a requirement to display activity for each blog post.

I am stuck in creating the right schema for the database. There are several ways to achieve this kind of functionality (defining data structures embedded as blog posts and comments, creating a document for each action, etc.), but I couldn’t currently decide which one is the best in terms of performance and scalability.

For example, look at the implementation of the people I follow. Here is an example user document.

User = { id: Integer, 
         username: String, 
         following: Array of Users,
         followers: Array of Users,
       }

It seems trivial. I can manage the next field for each user action (follow / unsubscribe), but what if the user I'm currently running is deleted. Is it efficient to update all user records that follow the deleted user.

Another problem is creating a blog presentation from the people I follow.

 Post = { id: Integer, 
          author: User, 
          body: Text,
        }

So this is an efficient request for recent posts, for example:

 db.posts.find( { author: { $in : me.followers} } )
+5
source share
2 answers

(), ( NoSQL, ) ( ) . , , , . , .

, , - . FOLLOWS. - NoSQL NoSQL, , Neo4j. , , .

, ( ) NoSQL . , , , MongoDB, Redis Neo4j, RDBMS. . Spring 3 Spring Data, .

+3

, , " ". - , .

0

All Articles