Merging 2 tables in a single table with different schema

送分小仙女□ 提交于 2019-12-11 04:53:41

问题


I would like to sync a single table with the result of a Join between 2 tables. I designed these dbs for exercitation (the EQUI JOIN is between PERSON.AddressId and ADDRESS.Id):

How can I perform the provisioning of dbs and the synchronization?

Until now I developed some examples about common scenarios, like different table names, different column names or the removing of columns.

How can this be achieved?

-->FIRST DB<--

PERSON:

->Id(PK, int, not null)

->Name(nchar(10), not null)

->Surname(nchar(10), not null)

->AddressId(FK, int, not null)

ADDRESS:

->Id(PK, int, not null)

->Street(nchar(10), not null)

->City(nchar(10), not null)

->Country(nchar(10), not null)


-->SECOND DB<--

CUSTOMER:

->Id(PK, int, not null)

->Name(nchar(10), not null)

->Surname(nchar(10), not null)

->Address(nchar(10), not null)

->City(nchar(10), not null)



回答1:


As far as I can tell from the documentation, the Schema's need to match for the Sync to work. You can sync between tables with the same schema but different names using the GlobalName property of the DbSyncTableDescription. See JuneT's post:

http://jtabadero.wordpress.com/2011/05/08/synching-tables-with-different-table-names/

For this particular situation, I think you'd be best served by creating Person and Address on Second DB, then creating "Customer" as a view (also on Second DB) to present the two tables in a consolidated manner.



来源:https://stackoverflow.com/questions/11673708/merging-2-tables-in-a-single-table-with-different-schema

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!