我是否正确构建我的Firebase数据结构?

时间:2017-11-20 19:48:15

标签: firebase-realtime-database

我试图找出我的firebase数据库结构并有3个问题。

1 - 我的方式是否优于/高效?我试图根据我读过的关于fb的内容尽可能地保持浅薄。

2 - 如果我有一组数据," portal_coordinates",一旦符合条件,就会被复制到另一个父母(" all" vs."完成"),将在" portal_coordinates"下进行设置。理想吗?或者设置类似于"奖励"会更好?

3 - 1个应用程序可以有多个fb dbs吗?使用下面的示例,我可以将" portal_coordinates_ALL"在一个单独的数据库?我猜不了,我应该把我所有的信息都存放在1分贝以下。

{
"users": {
    "user01": {
        "email": "user01@gmail.com"
    },
    "user02": {
        "email": "user02@gmail.com"
    }
}
// best to list all awards regardless of true or false?
"awards": {
    "user01": {
        "first_time": true,
        "five_in_a_row": true,
        "share_with_friend": false,
        "create_your_own": false
    },
    "user02": {
        "first_time": false,
        "five_in_a_row": false,
        "share_with_friend": false,
        "create_your_own": false
    },
}
// or should it be broken up similarly to below, 'completed' and 'all'?
"portal_coordinates_COMPLETED": {
    "user01": {
        "california": {
            "san_francisco": {
                "location02": {
                    "latitude": "37.831502",
                    "longitude": "-122.292161"
                }
            }
            "los_angeles": {
                "location01": {
                    "latitude": "33.941544",
                    "longitude": "-118.408198"
                }
            }
        }
    }
}
"portal_coordinates_ALL": {
    // do we want to be this detailed?
    "california": {
        "los_angeles": {
            "location01": {
                "latitude": "33.941544",
                "longitude": "-118.408198"
            },
            "location02": {
                "latitude": "34.069045",
                "longitude": "-118.445294"  
            }
        }
        "san_francisco": {
            "location01": {
                "latitude": "37.784440",
                "longitude": "-122.408002"
            }
            "location02": {
                "latitude": "37.831502",
                "longitude": "-122.292161"
            }
        }
    }
}
// 'images' don't have any 'users' relationship but does have app relationship, place in database?
"images": {
    "image01": "http://www.petwave.com/~/media/Images/Center/Care-and-Nutrition/Cat/Kittensv2/Kitten-3.ashx"
    "image02": "http://www.puppyoung.com/wp-content/uploads/sh/shiba-shiba-inu-puppies-breed.jpg"   
}

}

0 个答案:

没有答案