Mongodb里我对于用户activities应该另建一个collection还是放在user collection里?
巴扎黑
巴扎黑 2017-04-21 11:16:18
0
1
593

我需要跟用户呈现他活动的时间轴

现在有两种方案一种是,
把用户的活动放在user collection里,缺点是可能会放很多东西
另一种方案是,
新建一张activities collection,用userId做index
但其实我并不需要同时看多个用户的activities

巴扎黑
巴扎黑

reply all(1)
大家讲道理

For your needs, it is recommended to add another collection and use userId for association, although mongodb gives priority to inline processing. Since analyzing your activities is used to create a user activity timeline, it is basically something every user should have. In addition, according to your description, activities will put a lot of things. Although MongoDB currently expands the size of a single document to 16M, if the content is too large, it will still exceed its limit, and it will also have a certain impact on queries, etc. For this situation, mongodb will also recommend making redundant connections to simulate SQL connection queries.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template