Firebase扇出结构的新闻馈送 [英] Firebase fan-out structure for news feed

查看:123
本文介绍了Firebase扇出结构的新闻馈送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 posts users 和其他节点的数据库,如经典的社交媒体应用程序。



我正在继续为我的应用程序实施最佳做法。现在我想重写我的新闻(用户的帖子,我遵循(像在Instagram的家庭标签))。

我读了一些关于 fan-out 策略,现在我很困惑如何正确地做到这一点。

所以,我有两个机会:


  1. 这里:每当用户添加新的 post ,这个所有信息将被复制到 users-timeline(users news strip)/ UID / postId:FULL INFO 全部 > followers 这个 user 。每一次编辑都会编辑这个 post 的每个提及。

  2. 每次用户添加新的 ,这个 postID 将被复制到 user-timeline(users news strip)/ UID / postId: true 用户的所有追随者。每一个编辑都只会编辑源文章。

b

解决方案

我建议你使用David's East的解决方案。正如我在帖子中看到的那样,他使用了Firebase的非规范化和数据扁平化,这是Firebase中最好的常见做法。我还建议您阅读 NoSQL数据建模技术正确地构建您的火力地堡数据的复杂应用以更好地理解。



如果你有一个SQL的背景下,我建议你也看到大卫的东教程的针对SQL开发人员的Firebase数据库


I have a database with posts, users and other nodes like classic social-media app.

I'm continuing implementing best-practices to my application. And now I want to rewrite my news strip (posts of users, that I follow (like home tab in Instagram)).

I have read some info about fan-out strategy and now I'm confused in how to do it properly.

So, I have 2 opportunities:

  1. Like here: Every time user adds new post, this post with full information will be copied to users-timeline(users news strip)/UID/postId: FULL INFO to all followers of this user. And every edit will edit each mention of this post.

  2. Every time user adds new post, this postID will be copied to user-timeline(users news strip)/UID/postId: true to all followers of this user. And every edit will edit only source post.

Which logic is better with Firebase?

解决方案

I suggest you using David's East solution. As I see in his post, he uses Firebase denormalization and data flatten, which are the best common practices within Firebase.

I also recommend you reading NoSQL Data Modeling Techniques and Structuring your Firebase Data correctly for a Complex App for a better understanding.

If you have a SQL background, I recommend you seeing also David's East tutorial, The Firebase Database For SQL Developers.

这篇关于Firebase扇出结构的新闻馈送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆