M
M
makerkz2014-02-01 18:58:08
Database
makerkz, 2014-02-01 18:58:08

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}

There is a certain set of action types, which will be expanded later. Ultimately, all this will need to be parsed and output as a string, for example 'User has been logged in'. What is the best way to implement the structure of this type of table?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Shikanov, 2014-02-01
@dizballanze

The type is still better to take out in a separate field, in case you want to sort / group by type.

Y
Yuri Shikanov, 2014-02-01
@dizballanze

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 question

Ask a Question

731 491 924 answers to any question