我想創建一個簡單的社交應用程序來測試mongoDB的性能 例如,我發佈狀態「Hello every body,have a good day」 我的社交發送通知時,其他用戶「喜歡」,‘評論’,‘共享’開發用於通知的數據庫模式,如facebook
"A like your post" -> create a new notify
"B like your post" -> create a new notify
"C comment in your post" -> new no
"D comment in your post" -> new no
第一次,我嘗試設計像這樣
notify_post
{
"post_id":"",
"link" : "",//link to post
"type": ""//like comment or share
"u_id": // the Id of user that like, comment,...etc
}
喔,有一千通知,甚至暢想通知每天都 創建對於考試A,B,C也喜歡你的評論,C,D,E也在你的文章發表評論,我不認爲每個通知都像我們創建一個新的項目。 後來我有一個想法
我加3場進行後的文檔一樣,
post
{
"title":""
"content" :""
"like":[]//
"like_notify" : //0 or 1
"comment" [uid,uid]
"comment_notify" : //0 or 1
"share": [uid,uid]
"share_notify" //0 or 1
comment //rest...
}
每當我的帖子的標誌「comment_notify」用戶註釋轉向1告訴我,我的帖子有新評論
like "A comment in your post",
then C,D,E also comment in my post ,notify will be like that
"E,D and 2 others user also comment in your post"
"like" and "share" is so on
但是文件的大小限制是16MB,那是個好主意嗎?
你有任何的想法!感謝這麼多
你應該嘗試一下,看看有什麼效果最好,尤其是當你有興趣測試的MongoDB的性能。 – WiredPrairie 2013-02-21 12:01:23
我可以看到第二個設計的一個問題就是了解何時出現新事件。你知道誰對帖子發表了評論,但你不知道誰剛發表評論,以及他們是否在回覆原始海報時發佈了另一個回覆,但這一切都取決於你希望狀態如何真正起作用 – Sammaye 2013-02-21 12:21:11
是的,你是對的,如果有一位用戶在帖子中再次發表評論時會遇到麻煩,我想我們需要添加一個字段來標記帖子中最後一條評論的人,感謝您的建議 – 2013-02-21 12:45:16