这是我第一次使用Firebase创建应用程序。所以我是NoSQL的新手。在那之前,我使用了mysql。我如何构建一个与firebase中的更多1个表相关的表。它具有“一对多”的关系。我的关系表如下图所示:
这是我的结构,这是正确的方法吗?
{
"car_rental" : {
"car_rental_1" : {
"name " : "A rent",
"car" : {
"car_id_1" : true
}
}
},
"car" : {
"car_id_1" : {
"name" : "ABC",
"colour" : "red"
},
"category" : {
"car_category1" : true
}
},
"car_category" {
"car_category1" : {
"name" : "city car"
},
"car_category2" : {
"name" : "SUV car"
}
}
}
感谢您的帮助
答案 0 :(得分:-3)
阅读以下指南:
https://firebase.google.com/docs/database/web/structure-data
https://howtofirebase.com/firebase-data-modeling-939585ade7f4
这不是一个sql数据库,所以复制数据不是罪,这是一个“要求”,因为你有“无限”的存储空间。
你的实现的主要问题是你必须从数据库中查询数据,比如在sql模型中,如果你只是复制数据就更简单了,例如:
{
"car_rental":{
"car_rental_1":{
"name ":"A rent",
"car_id_1":{
"name":"ABC",
"colour":"red"
},
"category":{
"car_category1":true
}
}
}
},
"car":{
"car_id_1":{
"name":"ABC",
"colour":"red"
},
"category":{
"car_category1":true
}
}