Firebase扇出结构的新闻馈送 [英] Firebase fan-out structure for news feed
问题描述
我有一个包含 posts
, users
和其他节点的数据库,如经典的社交媒体应用程序。
我正在继续为我的应用程序实施最佳做法。现在我想重写我的新闻(用户的帖子,我遵循(像在Instagram的家庭标签))。
我读了一些关于 fan-out
策略,现在我很困惑如何正确地做到这一点。
所以,我有两个机会:
-
像这里:每当用户添加新的
post
,这个所有信息将被复制到
users-timeline(users news strip)/ UID / postId:FULL INFO
全部> followers
这个user
。每一次编辑都会编辑这个post 的每个提及。
每次用户添加新的
,这个 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:
Like here: Every time user adds new
post
, thispost
with full information will be copied tousers-timeline(users news strip)/UID/postId: FULL INFO
to allfollowers
of thisuser
. And every edit will edit each mention of thispost
.Every time user adds new
post
, thispostID
will be copied touser-timeline(users news strip)/UID/postId: true
to allfollowers
of thisuser
. 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屋!