热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

Nosql数据库设计-MongoDB

如何解决《Nosql数据库设计-MongoDB》经验,请问有什么解决方案?

我正在尝试构建一个只有以下3种模型的应用程序:

topic (has just a title (max 100 chars.))

comment (has text (may be very long), author_id, topic_id, createdDate)

author (has just a username)

Actually a very simple db structure. A Topic may have many comments, which are created by authors. And an author may have many comments.

I am still trying to figure out the best way of designing the database structure (documents). First I though to put everything to its own schema like above. 3 Documents. But since this is a nosql db, I should actually try to eliminate the needs for a join. And now I am really thinking of putting everything to a single document, which also sounds crazy.

These are my actually queries from ui:

Homepage query: Listing all the topics, which have received the most comments today (will run very often)

Auto suggestion list for search field: Listing all the topics, whose title contains string "X"

Main page of a topic query: Listing all the comments of a topic, with their authors' username.

Since most of my queries need data from at least 2 documents, should I really just use them all together in a single document like this:

Comment (text, username, topic_title, createdDate)

This way I will not need any join, but also save i.e. the title of topics multiple times.. in every comment..

I just could not decide.

I appreciate any help.


推荐阅读
author-avatar
Eosven_119
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有