User activity log tracking - SQL vs NoSQL?

I have a mysql database containing tables such as User, playlist, video, tags .

Based on this, I would like to get user activity in the application. usage example could 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, what would be the best alternative to develop a user flow diagram? relational(I am using MySQL) or NoSQL(non-relational, like MongoDB)

NoSQL Priority
a.) Another thing, since the activity covered will be huge, the data should be fast, I read that the Document Oriented database works well in such scenarios, since the connection between tables is not required
b) Since the activity log may contain no, one, many variables depending on the activity, a relational scheme may not be the best solution.

I would like to know more about this, please share your knowledge :)
Thanks you

+6
source share
2 answers

You are right, the main problem in any relational database is the union.

So you can create a tracking system in mongodb or in mysql, just avoid joins:

So, the structure will be like this:

 id activity_type - int user_id date field1 field2 filed3 

where activity_type (Registration = 1, CreatedPlaylist = 2, ...)

To avoid joining with a user table, you must add some user data (the data you need to display, for example first_name, last_name) to each activity line.

With the solution provided above, you can stay with mysql and the speed will be the same. Mongodb will be faster when you put a lot of things into a document that you need to combine into a relational database.

+4
source

As a long-standing relational user, it seems to me that the decision depends on whether you have financial transactions or tracking physical goods. β€œMoney and stuff” is what Relational was invented for. He is very good at this and maintains a very high level of correctness.

However, when you don’t need to balance books or make sure you don’t accidentally sell more widgets than you have, use whatever is convenient for you. Mongo, Sofa, whatever.

+1
source

Source: https://habr.com/ru/post/888780/


All Articles