简体   繁体   English

MongoDB集合

[英]MongoDB Collections

I am in the middle of developing an app which harvests tweets, Facebook statuses and Facebook photos for a user. 我正在开发一个为用户收集推文,Facebook状态和Facebook照片的应用程序。 Currently the user sets out exactly when and to they want this harvest to occur and a spider pulls the data during this period. 当前,用户确切地确定了他们希望何时进行收获,并且在此期间蜘蛛会获取数据。 The when and to is stored in a MySQL db and my plan was to store all the tweets, status and photo meta-data in MongoDB (with the actual images on S3). when和to存储在MySQL数据库中,我的计划是将所有tweet,状态和照片元数据存储在MongoDB中(实际图像在S3上)。

I was thinking I would just create one collection for each of the periods the user wants to harvest for and then store all the tweets etc from that period in that particular collection. 我当时想我只是为用户想要收获的每个时期创建一个集合,然后将该时期中的所有推文等存储在该特定集合中。

Does this seem like a reasonable approach? 这似乎是一种合理的方法吗?

Does this seem like a reasonable approach? 这似乎是一种合理的方法吗?

What the #1 user query? #1用户查询是什么? Is it "find activity by period" ? “按期查找活动”吗? If users only ever want to "find by period", then this makes sense. 如果用户只想“按周期查找”,那么这是有道理的。

However, if users want an accumulated view, now you have to gather history for a user and merge it for display. 但是,如果用户想要累积视图,则现在必须收集用户的历史记录并将其合并以显示。

If you want both a "by this period" and an "accumulated", then I suggest simply stuffing all data into a single user object. 如果您既要“在此期间”又要“累加”,那么我建议您简单地将所有数据填充到单个用户对象中。 It's easy to tag the individual actions with a "harvest run" and a "timestamp". 使用“收获运行”和“时间戳记”标记单个动作很容易。

Mongo Details : MongoDB can handle individual documents up to about 4MB. Mongo详细信息 :MongoDB可以处理最大约4MB的单个文档。 Most recent versions up this to 8 or 16MB. 最新版本将其增加到8或16MB。 If you're only using this space for text, please realize that this is a lot of text. 如果您仅将此空间用作文本,请意识到这是很多文本。 A copy of war & peace is just over 3MBs. 战争与和平的副本刚刚超过3MB。 So you're talking about hundreds of pages of text in 4MB. 因此,您正在谈论的是数百页4MB的文本。 With 8 or 16MB, you can probably store status updates & tweets for years on most people. 有了8或16MB,您可能可以将大多数人的状态更新和推文存储多年。

Note that MongoDB has GridFS for storing binary data (like image files), so you'll typically store just pointers to these in the User document. 请注意,MongoDB具有用于存储二进制数据(例如图像文件)的GridFS,因此您通常只在User文档中存储指向这些数据的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM