对MYSQL数据库实施版本控制的最佳方法是什么?

时间:2022-09-15 21:08:31

I have to produce a versioning system to store multiple versions of my articles in a database to allow the user to roll-back if required. My first thoughts are when the user wants to edit an article really I get the sql to no longer update but you insert their information back into the database. Currently the problem is i have an articles table and I am using the ID as my primary key to identify my article (so read more links and so on). If i insert into that table I will have basicly new articles, so I am thinking I need a new table for the older articles but then I have problem of the originals in that first table dbArticles, I also need so why of telling which article they have choosen, for example if they have 3 edits so 3 articles lets all made on seperate days may 1st,2nd and 3rd how I need to show they have choosen the 2nd of May version rather than the latest on the 3rd of May. Any help would be greatly receive thanks,

我必须生成一个版本控制系统,以便在数据库中存储我的文章的多个版本,以允许用户在需要时回滚。我的第一个想法是,当用户想要编辑文章时我真的让sql不再更新,但是你将他们的信息插回到数据库中。目前问题是我有一个文章表,我使用ID作为我的主键来识别我的文章(所以阅读更多链接等)。如果我插入到那个表中我会有基本的新文章,所以我想我需要一个旧表的旧文章,但后来我有第一个表dbArticles中的原始问题,我也需要这样,为什么告诉他们哪篇文章他们已经选择了,例如,如果他们有3个编辑所以3篇文章让我们分别在第1天,第2天和第3天制作,我需要表明他们已经选择了5月2日的版本,而不是5月3日的最新版本。任何帮助都会非常感谢,

Cool Hand Luke Uk

酷手卢克英国

Ps I am using PHP also and I am timestamping articles :D.

Ps我也使用PHP,我正在加时间戳文章:D。

2 个解决方案

#1


Have 2 tables:

有2个表:

  • article: here you store article_id, article name and any other meta data
  • article:这里存储article_id,文章名称和任何其他元数据

  • article_version: Here you store each version of the article (including the original one) and link with article_version.article_id=article.article_id. Be sure to add a timestamp and version etc in this table.
  • article_version:在这里存储文章的每个版本(包括原始版本)并链接到article_version.article_id = article.article_id。请务必在此表中添加时间戳和版本等。

#2


If you are after versioning of textual articles, you should consider using a wiki, for example MediaWiki. They may have solved the problem for you.

如果您正在对文本文章进行版本控制,则应考虑使用Wiki,例如MediaWiki。他们可能已经为您解决了这个问题。

#1


Have 2 tables:

有2个表:

  • article: here you store article_id, article name and any other meta data
  • article:这里存储article_id,文章名称和任何其他元数据

  • article_version: Here you store each version of the article (including the original one) and link with article_version.article_id=article.article_id. Be sure to add a timestamp and version etc in this table.
  • article_version:在这里存储文章的每个版本(包括原始版本)并链接到article_version.article_id = article.article_id。请务必在此表中添加时间戳和版本等。

#2


If you are after versioning of textual articles, you should consider using a wiki, for example MediaWiki. They may have solved the problem for you.

如果您正在对文本文章进行版本控制,则应考虑使用Wiki,例如MediaWiki。他们可能已经为您解决了这个问题。