这个系统设计可以改进吗?

Can this system design beign improved?

我是NoSQL的新用户,我想知道这个想法是职业玩家的举动还是新手的错误?

我想要实现什么

我正在设计使用 firebase 存储来管理数据,它的作用是允许注册用户将图像上传到不同的项目,例如不同主题的山、食物、家等, 所以你进入其中一个主题并上传一张与之相关的图片,这样当其他用户转到该部分(山脉、食物、家等)时,可以直观地看到已上传的内容。

问题

据我所见,用户无法存储具有唯一ID的图像,因此会有覆盖

“解决方案”

用户可以持有具有唯一 ID 的项目集合,因此当用户将图像上传到主题(如 Food)时,图像存储在他们自己的集合中,带有主题的标签,以及用户的 ID将保存在一个文件中。因此,当其他用户查看食物部分时,算法将查看上传照片的用户,然后查看他们的图片集以搜索标签,并检索该图片。

所以另一个问题可能是会有很多用户要搜索,所以我想到创建文件夹,其中包含具有相同 3 个首字母的所有用户。所以它会让搜索更容易。

问题

有没有办法让这东西变得更好?

任何文档或指南都会有很大帮助

谢谢

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.

听起来不错。在代码中应该是这样的:

val db = FirebaseFirestore.getInstance()
db.collection("photos").whereEqualTo("tag", "food")

Is there any way to make this thing better?

不,您找到了最简单易行的解决方案。