I have a website, where users can submit some text. Users can edit their posts and then save it. User can then go through all the changes he/she did to a post.
Problem:
Whenever they edit a post, I want to keep the old one and the edited one(s), but i don’t want to save the same part of the post many times.
My Approach
At first I wanted to save the original post, and then save just the appended text, but the problem I’m having is, that the edited part of the post is not always at the end.
How should I solve that?
You solve that with an algorithm that is specialized for such task, for example diff and patch. You either implement it your own, re-use an existing implementation or you use a software that is already finished that allows to store data in revisions.