如何在现有系统上合并标签
我们有一个简单的界面来标记特定问题
(e.g. entry has 1..many tags and each tag entry has a foriegn key pointer back to the entry table)
1. What is the current production version of the jdk? (Tags: jdk6 jdk-6 jdk java)
2. In what version was java.util.spi package introduced? (Tags: jdk-6, jdk7, jdk5)
3. Which version of java is going to be released soon? (Tags: jdk-6, jdk7, jdk8)
我们希望将所有名为“jdk-6”的标签合并到jdk6。我们如何在即将投入生产但包含有用数据的系统中实现这一目标。
在[1]中,需要删除jdk-6,因为jdk6已经存在。 [2,3]中jdk-6需要重命名为“jdk6”。
我需要什么样的脚本才能有效地迁移这些数据。
编辑
create table entry (id, question, ...)
create table entry_tag (id, entry_id, tag)
We have a simple interface to tag a particular question
(e.g. entry has 1..many tags and each tag entry has a foriegn key pointer back to the entry table)
1. What is the current production version of the jdk? (Tags: jdk6 jdk-6 jdk java)
2. In what version was java.util.spi package introduced? (Tags: jdk-6, jdk7, jdk5)
3. Which version of java is going to be released soon? (Tags: jdk-6, jdk7, jdk8)
We would like to merge all tags named as "jdk-6" to jdk6. How do we achieve this in a system which is nearing production but contains useful data.
In [1] jdk-6 needs to be removed, since jdk6 is already present. In [2,3] jdk-6 needs to be renamed as "jdk6".
What kind of scripts do I need to migrate this data in a effective fashion.
EDIT
create table entry (id, question, ...)
create table entry_tag (id, entry_id, tag)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会执行以下操作:
用好的标签更新“坏”标签 (
UPDATE TagTable SET Tag = 'jdk6' WHERE tag = 'jdk-6'
)删除重复的标签(其中entry_id 和 Tag 相同)。具体如何执行此操作取决于表上是否有单独的唯一键,但快速谷歌将为您提供在不同情况下工作的各种方法。
假设您有一个包含所有可用标签列表的 TagsList 表,请从中删除 jdk-6 (
DELETE FROM TagsList WHERE Tag = 'jdk-6'
)。I would do the following:
Update the "bad" tags with the good one (
UPDATE TagTable SET Tag = 'jdk6' WHERE tag = 'jdk-6'
)Remove the duplicate tags (where entry_id and Tag are the same) . Exactly how you do this will depend on whether you have a separate unique key on the table or not, but a quick google will provide you with a variety of methods that work under different circumstances.
Assuming you have a TagsList table with the list of all available tags, remove jdk-6 from it (
DELETE FROM TagsList WHERE Tag = 'jdk-6'
).我首先创建一个新表,其中包含包含标签“jdk-6”或“jdk6”的条目 ID 列表。
然后我将删除标签“jdk6”和“jdk-6”的所有标签记录。
然后我将使用开始时创建的表将它们添加回来。
I would first create a new table with a list of entry IDs that contain either of the tags 'jdk-6' or 'jdk6'.
Then I would remove all tag records for the tags 'jdk6' and 'jdk-6'.
And then I would add them back in using the table created at the start.