After reading a lot of SO questions about Keeping page changes history or How to version control a record in a database (for example), I can't find a real elegant solution to do the work.
Now, let's try to explain as clear as possible what we need, for this simple revision system, that allows registered users to post some articles, and other users to submit a revision of those articles, and then some moderators users to check those revisions.
MySQL database
The database contains an articles table with the following simplified fields:
ARTICLE(id, id_user, title, content, date);
To implement the revision/history versions, I guess that we'll have the following table:
REVISION(id, id_article, revision_id_user, id_moderator, revision_date,
revision_title, revision_content, revision_description, revision_check);
With the relation : ARTICLE 0,n <---> 1,1 REVISION
Workflow
A user create an
ARTICLE
, which is inserted in theARTICLE
table (terrific !)Another user makes an update of this
ARTICLE
, this update is recorded in theREVISION
table, and is queued for the moderator users. (revision_check=0
).A moderator user validate the
REVISION(revision_check=1)
, then theARTICLE(content)
gets theREVISION(revision_content)
value.
My questions
- Is this workflow seems to be a good way to do it? Because, I see a mistake: if there are several
REVISION
s for anARTICLE
:
- Should we take the content of the last submitted
REVISION
or the originalARTICLE
? - Or, should we need to block the revisions as no other
REVISION
could be submitted while the last isn't checked.
Is there a way to record light versioning? By the way, is it possible to insert in the
REVISION
table, only the updated content through a SQL, PHP or js compare function? And how to display it like SO do it? Because I'm afraid that theREVISION
table will be very heavy.Bonus : how does SO?
Any idea, link, source, plugin (MySQL, PHP 5 and JS/jQuery) would be greatly appreciated.