0
votes

Im new to Firebase, I have Structure my Data on firebase using Indices for maintaining relationshi as described in below articles

https://www.firebase.com/docs/web/guide/structuring-data.html https://www.firebase.com/blog/2013-04-12-denormalizing-is-normal.html

I just want to clear my retrieval concept on firebase.

as mention in above links

{  
  links:{  
    link1:{  
      title:"Example",
      href:"http://example.org",
      submitted:"user1",
      comments:{  
        comment1:true
      }
    }
  }
}

when I access link1, response contains link1 data as well as comments: {comment1:true}. Instead of comment1 actual text, accessing link1 gives comment's ID i.e, comment1. its mean when I access link1, it gives me the Ids of comments belongs to that link. so I have to retrieve comments mannually requesting firebase again based on comments ids received in link1 response? Please clear my concept : )

1
@Grant , Firebase preffered flatten data. You can see here .firebase.com/blog/2013-04-12-denormalizing-is-normal.html - Zaid Mirza
@Grant . Code is just a sample. my actual work is not on links and comments but something likes it. one to many relation - Zaid Mirza
@Grant. I have took this piece of code from article which I mention above in comments - Zaid Mirza
Yes, you will indeed have to load each items. Essentially you're doing a client-side join operation. Contrary to what many developers expect, this is a quite fast operation in Firebase for reasonable sizes lists. See my answer here for why that is: stackoverflow.com/questions/35931526/… - Frank van Puffelen
Is the goal to get all the comments for link1? - Jay

1 Answers

1
votes

Yes, your concept is correct, you will flatten out the data in firebase and then retrieve comments by using the id from the previous read