Last post May 16, 2012 09:38 AM by AidyF
May 15, 2012 10:37 AM|dofoo|LINK
I'm developing a CMS that give the users (with different administration levels) the possibility to write articles of a blog.
- a "power user" (level 2) write an article and publish it, the article will not be published instantly and it's in a "wait for approval" state.
- "admin user" (level 1) review the article and then publish it.
No problem to imagine and design the database for this.
Problems occours when someone MODIFY ARTICLES PREVIOUSLY PUBLISHED.
- a "power user" (level 2) modify an article. The modified article remains in a "wait for approval" state and the old one (without these last changes) is still visible in the front-end, the old one is replaced when the modified article is approved.
How can I design db and application considering this particular thing?
I know that worpress use revisions but I don't know how it's implemented and designed
I'm searching for the better approach to develop a good product
May 15, 2012 01:33 PM|AidyF|LINK
You can have an entry in the article table for your blog that contains all the usual fields, however rather than the text of the entry, have a "published revision" number instead. In a seperate table have the text;
Article_ID, Revision (these two will be the PK), Text
That allows you to maintain a single instance of the article, and you can join your second table on the published revision number to get the "live" text, but your edit tools can show the latest revision for editing. When that revision is marked as final,
the published revision in the article table is updated to reflect this. This architecture will also let you roll back to any previous revision simply by changing the published revision number.
May 15, 2012 07:00 PM|atconway|LINK
That allows you to maintain a single instance of the article
I think this should read: "That allows you to maintain a single instance of the article
per revision," which then supports your last statement:
This architecture will also let you roll back to any previous revision simply by changing the published revision number.
May 16, 2012 09:38 AM|AidyF|LINK
Let's say your tables are Article and Article_Data with the Article containing fields like who created it, when it was created, last edited, current revision ID plus any other fields you want to store about it. Article_Data will contain revision ID, Title
and Content. You can maintain a single instance of "Article"...ie the Article will only exist the once for the purposes of your data retrieval, searching etc, you're never going to get 5 versions of the article in search results...but what is held multiple
times is Article_Data. So when you need to show a summary of your article you join Article and Article_Data on article_ID and live_revision, but your admin tools can show all instances of Article_Data and let you amend/publish/unpublish etc.