I am a new user of NoSQL, and I want to know if this idea is a pro gamer move or a newbie error?
WHAT I WANT TO ACHIEVE
I am designing that uses firebase storage to manage the data, what it does is allow the registered users to upload images to different items, such as, mountains, food, home, etc on different topics, so you go into one of those topics and upload an image related to that, so when other users go to the section (mountains, food, home, etc), can visualize what has been uploaded.
THE PROBLEM
As long as I have seen, a user cannot store an image with an unique ID, so there will be overrides
THE "SOLUTION"
A user can hold a collection of items with uniques IDs, So when a user Uploads an image to a topic like Food the images storages in their own collection with a TAG of the topic, and also the Id of the users will be saved in a file. So when other users look at the section of Food, the algorithm will look at the users who uploaded the photo then look at their collection of images in search of the Tag, and retrieve that image.
So another issue could be that there will be a lot of users to search on, So it crossed my mind to create folders, that contain all users that have the same 3 initial letters. So it will make the easier search.
QUESTION
Is there any way to make this thing better?
Any documentation or guide will help a lot
Thank you
CodePudding user response:
So when a user uploads an image to a topic like Food the images storages in their own collection with a TAG of the topic and also the Id of the users will be saved in a file.
Yes, that's a common practice.
So when other users look at the section of Food, the algorithm will look at the users who uploaded the photo then look at their collection of images in search of the Tag and retrieve that image.
Sounds good. In code should look like this:
val db = FirebaseFirestore.getInstance()
db.collection("photos").whereEqualTo("tag", "food")
Is there any way to make this thing better?
No, you found the simplest and easiest solution.