使用Firebase创建Twitter等页面

时间:2016-10-09 18:49:33

标签: android firebase

我向Firebase社区提出了一个问题。

如何为Twitter这样的#page构建数据? (例如:#funnyVideos以便任何人都可以在Firebase中看到该链接并添加一些内容)?

1 个答案:

答案 0 :(得分:1)

听起来你正试图存储哈希标签。

但这还不足以确定您的数据模型。

在Firebase中(与大多数NoSQL数据库一样),您可以根据应用程序使用的方式为数据建模。因此,您必须确定应用中的屏幕以及它们显示的信息。

例如,如果要显示每页的哈希标记,则每页都存储一个哈希标记列表:

hashtagsPerPage
    pageId1
        hashTag1: true
        hashTag2: true
    pageId2
        hashTag1: true
        hashTag3: true

如果您还想要一个给定哈希标记的页面列表,那么存储:

pagesPerHashtag
    hashTag1
        pageId1: true
        pageId2: true
    hashTag2
        pageId1: true
    hashTag3
        pageId2: true

当然,您自己拥有页面列表:

pages
    pageId1
        title: "Creating # pages like Twitter with Firebase"
        url: "http://stackoverflow.com/questions/39947270/creating-pages-like-twitter-with-firebase"
    pageId2
        title: "Structure Your Database"
        url: "https://firebase.google.com/docs/database/web/structure-data"

我强烈建议您同时阅读Firebase documentation on data structuring(前两个列表是第34节中记录的结构;创建可扩展的数据")。

此外,NoSQL data modeling上有这篇精彩的入门书。