博客应用的Firebase数据库结构

时间:2018-04-04 08:49:16

标签: json firebase firebase-realtime-database

1)构建数据库是否更好:

   blogapp
            -User
                id
                name
                 ...
            -Post
              id
              users
               -a unique id
                          -userId
                          -contentOfPost

2)为UserPost使用单独的节点

blogapp
     -User
     ...
    -Post

    -UserPost
     -unique id
               -userId
               -PostId

谢谢

1 个答案:

答案 0 :(得分:2)

是使用单独的UserPost

Users
  userid
    name: userx
    email: userx@gmail.com
  userid1
    name:usery
    email: usery@gmail.com

UserPost
    userid
      author:userx
      postcontent: content_here
      posttitle: title_here 
    userid1
      author: usery
      postcontent: content_here
      posttitle: title_here

更多信息:

https://firebase.googleblog.com/2013/04/denormalizing-your-data-is-normal.html