firebase - 这是构建我的firebase数据库的好方法吗?
问题描述
我刚开始使用 Firebase(从 MySQL 开始),在阅读了许多文档/观看教程之后,我尝试为我的“Ebay/Gumtree 风格的应用程序”构建数据库。我所做的有什么重大问题吗?
我试图在我的应用程序的每个屏幕周围构建它,这样我就不会读取不需要的全部数据(我认为这是我应该采用的扁平结构?),但是这个导致了一些数据重复(特别是图像)。
这是构建数据库的好方法吗?我从这里得到了一些提示:
{
"users": {
"user1": {
"email": "example@gmail.com",
"password": "********",
"first name": "Example",
"last name": "User",
"age": "45",
"gender": "Male",
"address": "XX1 9YY"
}
},
"upload image": {
"user1": {
"image1": { #path to image
"condition": "Like New",
"price": "£100",
"upload date": "10/10/2019",
"promoted": True,
"promoted expiry": "11/11/2019"
},
"image2": {
"condition": "New",
"price": "£250",
"upload date": "12/12/2019",
"promoted": False
},
"user2": {
"image1": {
"condition": "Used",
"price": "£50",
"upload date": "05/05/2019",
"promoted": True,
"promoted expiry": "06/06/2019"
}
},
"promoted images": { #max 50 images stored here
"user1": {
"image1": #This image is a duplicated of the image above
"condition": "Like New",
"price": "£100",
"upload date": "10/10/2019",
"promoted": True,
"promoted expiry": "11/11/2019"
},
"user2": {
"image1": { #This image is also a duplicate
"condition": "Used",
"price": "£50",
"upload date": "05/05/2019",
"promoted": True,
"promoted expiry": "06/06/2019"
}
},
"categories": {
"category1": {
"image1": { #This is the third location image1 is stored
"condition": "Used",
"price": "£50",
"upload date": "05/05/2019",
"promoted": True,
"promoted expiry": "06/06/2019"
},
"image2": {
"condition": "New",
"price": "£250",
"upload date": "12/12/2019",
"promoted": False
}
},
"reviews": {
"user1": {
"review1": {
"rating": 4,
"message": "delivered on time, thanks"
},
"review2": {
"rating": 5,
"message": "great product, delivered quickly"
},
}
"user2": {
"review1": {
"rating": 1,
"message": "terrible service, took ages to arrive and was faulty!"
},
},
},
},
}
关于我到目前为止所做的事情的一些问题/想法:
拥有同一图像的多个副本是否是一个好主意,因为它可以节省 1000 多个图像。例如,如果我没有“推广图片”但想查找所有推广图片,我必须搜索“上传图片”部分(其中的图片比“推广图片”中的 50 张多得多
每个“类别”都是一个新屏幕,将加载大量图像,因此我尝试将这一部分分开,而不是拥有一个每次加载任何页面时都会读取的主“类别”。
谢谢
解决方案
推荐阅读
- angular - Angular 7 添加价格、数量和服务的增值税动态添加到表单数组中
- javascript - 使用 AJAX 从 API URL 解析 JSON
- amazon-web-services - AWS 账号是随机的还是数字说明了一些信息?
- c# - Telerik UI 组件与 GitHub 存储库的集成
- .net - NewtonSoft 反序列化到 JObject 非常慢
- excel - 计算字段 - 产品总和
- redux - Calling a function from another component with redux
- python - AttributeError:“模块”对象没有属性“ST_SIZEGRIP”
- amazon-connect - 使用 Amazon Connect 的计划回调
- python - 为熊猫数据框的每一行替换一列中的字符串