Answer the question
In order to leave comments, you need to log in
How to store versions of texts?
Let's say I need to store versions of texts. I'm guessing this:
texts
- id
- author_id
...
versions
- id
- text_id
- text
Note that I don't store text in the text table, only in versions. When creating a new text, I also create a new version and save the text there. Right move?
Answer the question
In order to leave comments, you need to log in
You can organize versioning based on one table, just add a field with a timestamp to the table. When changing, we simply add a new record with a new timestamp. To select the current record, select the record with the highest timestamp. An interface for viewing changes, etc. is easily made.
To delete, you need to create a status field where the sign of deletion will be written, do not physically delete the records.
I have repeatedly seen a similar scheme of tables with history in banking software.
You can store patches. If the text sizes are large and there are a lot of them, then the space will be spent more economically. But to restore the full text of a certain version in this case, it is necessary to patch the original version the required number of times.
You can hang a trigger on the change, add, delete events so as not to program all the business logic. From the trigger it is possible to write though in the next column, though in the next table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question