bugthesystem / FireSharp

An asynchronous cross-platform .Net library for Firebase
The Unlicense
696 stars 147 forks source link

FireSharp Retrieval Concept #41

Open Zaid-Mirza opened 8 years ago

Zaid-Mirza commented 8 years ago

Hi Scenario is,

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 : )

Zaid-Mirza commented 8 years ago

any body available?

jviaches commented 7 years ago

Hello @Zaid-Mirza, Let me try to answer your question. FireBase approach is basically has two ideas of containing data:

  1. One-directional, meaning that we actually nest the child objects under the parent.
  2. Two-way relationships we basically duplicating some data.

First one has some underlying meaning: when some entity has access to specific node, it also has access to all its descendants. I mean it's not good or bad thing, developer should be aware of this behavior. Another point here is that if db has a millions of descendants for node we trying to retrieve from database, it can be painful :)

In a second approach we duplicating data but this is necessary. The idea is that you load some data you need and then go to related node and fetch additional information required for first fetch.

Here is the link that might be helpful for you : https://firebase.google.com/docs/database/web/structure-data

Hope i succeeded to get to the point :)