I have to store data like articles into a mysql database and if an article is modified, I have to save the old version as well to make it possible to restore it. I have found some similar questions and posts on this topic, but I am not sure, which solution is the best to solve the problem.
Here is the basic table "articles" for better understanding:
articles (id, name, text)
For me, there are two different approaches for this:
Approach 1
Store the data and every version of an article in the table "articles" and add the columns "version" and "status". In version i store the incremented version number of the article. The active article gets the "status" 1 and the others the "status" 2.
Pro's:
Con's
- Very large tables (maybe slower queries???)
Approach 2
Add the field "version" to "articles" and store only the active data into the table "articles". Old versions of the data is stored / moved to the new table "articles_versioned".
Pro's:
- Only the actual valid data is in the table "articles"
Con's
So. Have I forgotten a good aproach? How to deal with related data in other tables (like images, etc.)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…