Hi community,
This is my first question here and therefore my apologies if i have missed any sort of convention / rules on how to do so properly.
I also checked multiple documentation on this platform and searched the web for adequate answers on the below questions, however to no real satisfaction. Therefor i hope you could help out / point me in the right direction. Thanks in advance
I have been working with FF for a few months now and am at a point that by testing my app (a score tracker for sports) i see my database (FireBase) gets way to many READs, which makes sense since in the Netherlands alone, there are 3500 amateur football clubs. It made me realise i need to efficiently structure my database. In order to do this i found out about the principles of Datatypes and Subcollections, however i dont find any real explanation how they work in order to understand the way to use these efficiently:
Datatypes:
I understand you can group certain fields in one and therefore have a much better readability in the database as well as the omittance of doing the same thing more than once. ie. 1 fields (Statistics) holds 4 fields (goals, assists, yellow cards and red cards). My question here is if the actual read of the grouped fields (Statistics) is READ as 1 read or 4?
Subcollections:
How does a query (Query Collection) "work" if there is a filter:it "reads" all (parents) documents and then filters the "filter" --> result: many costs, or
it "reads" only the filter and therefore only costs the filtered results --> result: only filtered, or
any other structure?
Since you can query a parent and then use the subcollections data, is the other way around also possible? So example: i have a football Player as the parent document, with subcollections below it, such as the earlier mentioned Statistics. I understand i can query the player (parent) and use the subcollection attached. But can i query the subcollection (es with a reference) but then move into / use the parents data?
Thanks again and looking forward to your repy
best
Daan