U
U
Urukhayy2015-12-18 14:43:44
Programming
Urukhayy, 2015-12-18 14:43:44

Is it normal to keep a history of changes to all properties of an application entity in a mysql table?

Is it normal to keep a history of changes to all properties of an application entity in a mysql table?
For example:
There is a browser application (game). This game has character levels, for example. When a character levels up, instead of changing that character's line in the level table, a new line is created with the new level. The old line with the old level remains. If you add datetime to each such line, you will get a history of when the character received which level.
When you need to know the current level of a character, a query is made on the last datetime of this character.
And so to all the properties of this character. For example: weapons, experience, etc.
In what case, in your opinion, should properties be included in such a "story" at all?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Riccky, 2015-12-18
@Riccky

You can see why you need it. For me, it’s only for all sorts of showdowns with cheaters, cheaters and in case of problems with payments.
But I wouldn't keep it that way. I would store the history separately, and the last value separately, so that the selection for the current value could be done without specifying the "last datetime". Since history is not needed for everyday work, there is no need to load the server with unnecessary work. Then, as the complexity of the game and the number of players increase, you will have performance problems if you do as you wrote.
And it would be because of what. Not because of what - viewing history is not the most frequent and not the most necessary operation.

P
Pavel K, 2015-12-18
@PavelK

If you torture the server database on any sneeze, it will fall very quickly from the number of users, as they wrote in the top post.
I would suggest storing the history (and everything that is not important for the process) on the client,
and from time to time synchronize / upload everything at once to the main database.
More precisely, yes, not in the main, but in a separate one.

V
Visphord, 2015-12-28
@Visphord

I have in one fin. the system had a similar pattern - there was a trigger on UPDATE + INSERT, which added all fields + DateTime to the table_name_log. It worked, but there is one caveat. If suddenly someone comes and makes update table set amount=amount+1, then the database will be sooo bad.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question