1

Guys need some input creating a data structure that can be scaled for my use case.

I as a user can have many followers & can follow others too. So when I create a post my followers should get it. The Typical use case similar to Twitter or FB, but not so complex.

So for Instance I(Joseph) follow 2 users, hence my feed should be populated with the posts from the users I follow.

A Base structure defined as of now

How can I fetch the posts of persons I follow. Or please guide on how to achieve the same using Firebase Realtime DB (NoSQL)

1 Answer 1

1
{
 "following":{
    "josephid":{ 
       "name"  : "joseph"
       "naber" : true
       "roger" : true
 }
}
 "followposts":{
        "pushid":{
          "foriegnid": "pushid1"
          "foriegnfollowid": "josephid"
       }
       "anotherpushid":{
         "foriegnid": "pushid2"
         "foriegnfollowid": "josephid"
       }

 }
}

Create another node that will take the ids in the node post and the id of the current user. That way the people that person is following and the posts are connected with each other. The Foriegnid and foriegnfollowid is just a name not an id but the value is the pushids of the posts and the userid

Sign up to request clarification or add additional context in comments.

5 Comments

Okay so now we have the id's. But doesn't require this querying each and every posts to get the data.
check this link firebase.com/docs/android/guide/… @SharanMohandas
You can nest it, but this is a better option. The link above actually have doc for all three platform on how to join @SharanMohandas
Yeah, I was apprehensive about having multiple requests for each posts. But Firebase itself encourages it. Shall look at how this approach performs
@SharanMohandas yes i think this approach will work out, since its logical

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.