如何通过在新数据库中迁移的外键关联两个表?

时间:2018-11-14 18:12:42

标签: sql sql-server tsql

所以基本上我的旧数据库中有两个表,其中Product具有引用SubCategory的外键:

Product(ProductKey,ProductSubcategoryKey, other fields...)
ProductSubCategory(ProductSubcategoryKey, EnglishProductSubcategoryName, SpanishProductSubcategoryName,FrenchProductSubcategoryName)

现在我的新数据库中有三个新表,其中SubCategory中的CategoryID是引用Category的外键。 SubCategory和Category都通过ProductTranslation获得其翻译,并且都获得了CategoryTranslationID:

SubCategory(ProductSubCategoryID,CategoryTranslationID,CategoryID)
Category(ProductCategoryID,CategoryTranslationID)
ProductTranslation(CategoryTranslationID,CategoryName_FR,CategoryName_EN,CategoryName_ES,categorytype)

现在,我的问题是将两个表从旧数据库迁移到新数据库中的三个新表中,同时保持它们之间的关系不变,而迁移硬数据不是那么困难,而保持它们的外键关系才是我发现了一个巨大的挑战,被困住了。

非常感谢您!

0 个答案:

没有答案