跟踪用户活动日志 - SQL 与 NoSQL?
我有一个 mysql 数据库,其中包含用户、播放列表、视频、标签等表。
基于此,我想收集应用程序上的用户活动。示例用例可能是:
a.) (user) joined (app) on (date)
b.) (user) created playlist (playlist) on (date)
c.) (user) added (video(s)) to playlist (playlist)
d.) (user) added tags (tag(s)) to video in playlist (playlist)
给定这样的数据,哪一个是设计用户活动模式的更好替代方案? 关系型(我使用 MySQL)或 NoSQL(非关系型,如 MongoDB)
喜欢 NoSQL
a.) 另一件事是,由于活动量很大,检索数据应该很快,我读到面向文档的数据库在这种情况下表现良好,因为不需要表之间的连接
b.) 由于活动日志可能不包含、一个或多个变量,具体取决于活动的发生,因此关系模式可能不是一个好的解决方案。
我想了解更多相关知识,请分享知识:)
谢谢
I have a mysql database containing tables like User, playlist, videos, tags.
Based on this I would like to collect the user activity on the application. the example use cases may be :
a.) (user) joined (app) on (date)
b.) (user) created playlist (playlist) on (date)
c.) (user) added (video(s)) to playlist (playlist)
d.) (user) added tags (tag(s)) to video in playlist (playlist)
Given such data, which would be better alternative to design a user activity schema? relational(I am using MySQL) or NoSQL(non-relational, like MongoDB)
Favoring NoSQL
a.) The other thing is since activity lit will be huge, retrieving data should be fast, I read Document Oriented database performs well in such scenarios since no joining between the tables is needed
b.) Since the activity log may contain no,one,many variables depending upon the activity happening, a relational schema might not be a good solution.
I would like to learn more about it, please share the knowledge :)
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你是对的,任何关系数据库的主要问题都是连接。
因此,您可以在 mongodb 或 mysql 中创建跟踪系统,只需避免连接:
因此结构将如下所示:
where Activity_type (Signup = 1, CreatedPlaylist =2, ...)
为了避免与用户表连接,您应该添加一些用户每个活动行的相关数据(您需要显示的数据,如名字、姓氏)。
通过上面提供的解决方案,您可以继续使用 mysql,并且速度将相同。当您在文档中嵌入许多需要加入关系数据库的内容时,Mongodb 会更快。
You are correct, main problem in any relational database is join.
So, you can create tracking system in mongodb or in mysql, just avoid joins:
So structure will be like this:
where activity_type (Signup = 1, CreatedPlaylist =2, ...)
To avoid join with user table you should add some user related data (data, that you need display, like first_name, last_name) to each activity row.
With provided above solution you can stay with mysql, and speed will same. Mongodb will be faster when you embedd in document many things, that you need join in relational database.
作为一个长期的关系型用户,在我看来,这个决定取决于您是否进行金融交易或跟踪实物商品。 “金钱和东西”就是关系型技术被发明的目的。它非常擅长并保持非常高的正确性标准。
但是,当您不必平衡账簿或确保不会意外出售比您拥有的更多的小部件时,请使用您觉得舒服的东西。蒙戈,沙发,等等。
As a long-time Relational user, it seems to me the decision hinges on whether or not you have financial transactions or the tracking of physical goods. The "money and stuff" is what Relational was invented for. It is extremely good at it and maintains a very high standard of correctness.
However, when you do not have to balance books, or make sure you don't accidentally sell more widgets than you have, then use what you are comfortable with. Mongo, Couch, whatever.