Good use-case for sub-collections is data security. They become pretty useful when writing complex rules. Here is an example: Say we want each user to have a user profile that all other users can see, but we want certain things to be private. We can store the private data in a sub-collection and use a security rule to limit access to it. Using this technique you can get quite sophisticated access scenarios achieved, things like dynamically set privacy settings on a social media platform.
Yes! I've been using sub-collections recently for private chat rooms, and they're great for easy security. I still try to avoid them... but I've definitely found a few good use cases like this. My problem with sub-collections is that they're easy to misuse. I mean... that's not sub-collections' fault... it's user error. And I mostly hear the stories of user error, so I'm extra-sensitive to it.
Indeed, when you choose to use a sub-collection you had better have a good, well thought out reason for it. Otherwise I would stick to a shallow structures with lots of denormalizing so queries are simpler and quicker.
I keep my code tables in subcollections. I have a collection called code-table, a doc for each code table, for example day, unit, etc. So I can easily retrieve all units by querying 'code-table/unit/*'. The number of entries/docs in subcollections are unlimited, unlike the 1 MB json for nested objects.
That was an interesting point of view, and I agree, sub collections are clumsy. But to avoid the problem of orphan sub-collections, I put a boolean description in the document : has_ingredients : True .. this way I know if the sub collection "ingredients" exists or not , and I can query it etc... What do you think of this approach ?
Well, documents have a 1mb and a 20k field limit and you can't download them partially. Also there is a 1 write per second limit. For a lot of use cases this is not enough, like chat messages.
I love your vídeos. They are full of good and deep knowledge. Now I will look into your Udemy course. ;) If I may suggest, if you adjust the volume of intro's music similar to that of speech, it will sound better. I have noticed that the muisic is much louder than the speech. RU-vid has recommendations for this, which are -13 LUFS. I prefer -23, which is lower. Adobe Premiere has a button that does this automatically in sound effects. Other programs should have as well.
Hello I encountered a problem using the sub-collection, due to this I am unable to progress any further, would you mind taking a look into the problem and provide me a feedback? I have posted the problem is Stack overflow and have yet to received a response. If you do I can provide the link to stackoverflow
@@ChrisEsplin Hi, could you help me? I have a dilemma about how to have data that depends on others, a blog that has many categories and that the blog has many images. Collections (blogs, categories, images) sorry for English
Hi, maybe you could help me. I must make a mobile application for a store that stores users and those must have customer registration, products and sales ... should I use subcollections or could I use only collections at the root level?