从SQL Server获取经过精确编辑的数据 [英] Getting the exact edited data from SQL Server

查看:93
本文介绍了从SQL Server获取经过精确编辑的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表格:


  1. 文章(artID,artContents,artPublishDate,artCategoryID,publisherID )

  1. Articles(artID, artContents, artPublishDate, artCategoryID, publisherID).

ArticleUpdated(upArtID,upArtContents,upArtEditedData,upArtPublishDate,upArtCategory,upArtOriginalArticleID,upPublisherID) / code>

ArticleUpdated(upArtID, upArtContents, upArtEditedData, upArtPublishDate, upArtCategory, upArtOriginalArticleID, upPublisherID)

登录到应用程序并通过(artContents)列更新文章
内容的用户。我想知道:


  1. 哪些会更改文章内容?

  1. Which Changes the user made to the article's contents?

我要存储文章,原始版本和修改版本的两个版本!

I want to store both versions of the Article, Original version and Edited Version!


我应该如何处理上述两个任务:


  • 对表格进行任何必要的更改

  • Any necessary changes into the tables?

获取 artContents)


  • (精确编辑的数据表示在列中可能有5000个字符,用户可以在中间或其他位置编辑200个字符在列的字符中,我想要编辑之前和编辑之后的那些编辑的字符)

注意:我使用ASP.NET与C#开发

推荐答案

不能够使用SQL进行确切的编辑。您需要一个算法,例如Unix diff 对文件(在行级别上工作)。在字符级别,算法将是 Levenshtein距离的一些变体。如果 diff满足你的需要,你可以下载它,编写一个存储过程来调用它,然后在数据库中使用它。这将是相当昂贵的。

You are not going to be able to do the exact editing using SQL. You need an algorithm such as the Unix diff on files (which works on the line level). At the character level, the algorithm would be some variation of Levenshtein distance. If diff meets your needs, you could download it, write a stored-procedure to call it, and then use it in the database. This would be rather expensive.

您维护不同版本的问题的部分更容易。我将在每个记录上添加两个colmnns​​ EffDate EndDate 。您可以通过查找 EndDate is NULL 获取最新版本,并在任何给定时间找到活动的版本。 合并通常用于维护此类表。

The part of your question of maintaining the different versions is much easier. I would add two colmnns EffDate and EndDate onto each record. You can get the most recent version by looking for EndDate is NULL and find the version active at any given time. Merge is generally useful for maintaining such a table.

这篇关于从SQL Server获取经过精确编辑的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆