1

I started developing simple app to learn Firebase, I followed cool blog post: https://firebase.googleblog.com/2013/04/denormalizing-your-data-is-normal.html

In my app, I want to store user profiles (its extension of firebase user) and relationship between users (something like friendship)

I came up with this data structure idea:

profile 
    profile1:
        userName:"User 1",
        userDescription: "User 1 description"
    profile2:
        userName:"User 2",
        userDescription: "User 2 description"
    profile3:
        userName:"User 3",
        userDescription: "User 3 description"


profileFriends:
    profile1:
        profile2: true

    profile2:
        profile1: true
        profile3: true

    profile3:
        profile2: true

Of course instead of profile1 I use pushed keys.

I wonder I its okay for such a use case - I want to display all friends of profile2.

I have to get Database reference to

"profileFriends/profile2"

And then iterating childs gives me keys: profile1 and profile3 which I can then listen using reference

"profile/profile1"
"profile/profile3"

Since Im working in Android, I can wrap all this code and use Observable that emits profiles. Question: Do I get this right? I have some SQL background and standard request-response api experience, Im just little worried if my user have 100 friends Ill need to make total 101 listeners - is it similar to make 101 requests? Is there any smarter way to solve "join" in non-joinable no-sql database? I guess another solution is denormalization, but I'm not a big fan of updating many places to change for example profile description

  • Loading 100 items is not as expensive on Firebase as you may think. See http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786 – Frank van Puffelen Jul 26 '16 at 13:45

0 Answers0