我开始开发简单的应用程序来学习Firebase,我关注了很酷的博文:https://firebase.googleblog.com/2013/04/denormalizing-your-data-is-normal.html

在我的应用程序中,我想存储用户配置文件(firebase用户的扩展名)和用户之间的关系(类似于友谊)

我想出了这个数据结构的想法:

profile 
    profile1:
        userName:"User 1",
        userDescription: "User 1 description"
    profile2:
        userName:"User 2",
        userDescription: "User 2 description"
    profile3:
        userName:"User 3",
        userDescription: "User 3 description"


profileFriends:
    profile1:
        profile2: true

    profile2:
        profile1: true
        profile3: true

    profile3:
        profile2: true

当然,我使用推键而不是profile1 .

我想知道我对这种用例没问题 - 我想展示profile2的所有朋友 .

我必须得到数据库参考

"profileFriends/profile2"

然后迭代子项给我键:profile1和profile3然后我可以使用引用来监听

"profile/profile1"
"profile/profile3"

由于我在Android中工作,我可以包装所有这些代码并使用发出配置文件的Observable . 问题:我说得对吗?我有一些SQL背景和标准的请求 - 响应api体验,我只是担心如果我的用户有100个朋友我需要总共101个听众 - 是否类似于101个请求?有没有更聪明的方法来解决不可连接的no-sql数据库中的“join”?我想另一个解决方案是非规范化,但我并不是更新许多地方的忠实粉丝,例如简介描述