新闻提要的 Firebase 扇出结构

Vla*_*hev 6 nosql firebase firebase-realtime-database

我有一个数据库postsusers以及其他节点,如经典社交媒体应用程序。

我正在继续对我的应用程序实施最佳实践。现在我想重写我的新闻条(我关注的用户帖子(如 Instagram 中的主页标签))。

我已经阅读了一些有关fan-out策略的信息,现在我对如何正确执行感到困惑。

所以,我有两个机会:

  1. 就像这里:每次用户添加新内容时postpost都会将带有完整信息的内容复制users-timeline(users news strip)/UID/postId: FULL INFO到所有内容followersuser。并且每次编辑都会编辑每次提及 this post

  2. 每次用户添加新的post,这postID将被复制user-timeline(users news strip)/UID/postId: true到所有followers这些user。并且每次编辑都只会编辑源帖子。

Firebase 哪种逻辑更好?

Ale*_*amo 4

我建议您使用 David's East 解决方案。正如我在他的文章中看到的,他使用 Firebase 非规范化和数据扁平化,这是 Firebase 中的最佳常见实践。

我还建议您阅读NoSQL 数据建模技术为复杂应用程序正确构建 Firebase 数据,以便更好地理解。

如果您有 SQL 背景,我建议您还查看 David 的 East 教程:面向 SQL 开发人员的 Firebase 数据库