VIN*_*RUS 2 firebase google-cloud-firestore
如何构建社交网络数据库结构,例如twitter
我们可以在时间轴上关注用户并获取其所有推文,我已经检查了此Firestore-如何构建提要和关注系统,
但帖子中的解决方案似乎存在缺陷。
Firestore是不同的,它需要冗余数据才能有效地访问数据,但是假设我正在跟踪1000个人,并且如果我需要通过查询我正在跟踪的15个用户的数据并使用limit(10)
方法来获取所有这些用户的信息,则orderBy(timeStamp)
可能未读查询之间的帖子,因为我们使用来获取帖子last post timeStamp
,如何在Firestore中构建社交媒体应用程序的数据
When modeling a use-case on a NoSQL database, you tend to optimize for the features of your application, and for frequent read-operations.
So in a social media application your main feature may be that the user sees the recent posts of everyone they follow. To optimize this operation for frequent reads, you'll want to store the posts that the each user should see in a document for that user. So when compared to Twitter, you'd pretty much have a document containing the twitter feed for each user. Or if there's too much data for a single document, you might want to put that in a collection. I often explain this as modeling the screens of your app in the database.
This is very different from the typical data model in a relational database, so it's normal that it takes time to get used to. For a good introduction, I recommend:
归档时间: |
|
查看次数: |
524 次 |
最近记录: |