Answer the question
In order to leave comments, you need to log in
Table structure with user actions
Good day!
There is a table with user actions, let's conditionally call it 'actions'. The table has the following columns: 'user', 'date', 'action'. I think no one will have any questions about the first two, but about the third: I would like to record user actions in the third column of the table in the form of a JSON object. You will get a kind of action log:
{type: REGISTRATION}, {type: DOWNLOAD, item: 34}, {type: UPLOAD, item: 25}
Answer the question
In order to leave comments, you need to log in
The type is still better to take out in a separate field, in case you want to sort / group by type.
Well, you would immediately write that this is MongoDB. There is no such thing as a table in it, there are collections.
Because Since there is no formal scheme in MongoDB, you can simply form the necessary types in the code, data for each of them, and write the whole thing into a separate collection. The only thing is to store the type always in the same field and hang an index on it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question