OK, it's like this - I have a situation where I have to import data from mutiple related tables into a structure with different related tables. So far not too bad. In the past when I've done this, all the data came from one source with one data structure, so I used the primary/foreign key data as it was structured in the orginal tables in my design for the tables I was going to use the imported data in.
Unfortunately, in this case I will be receiving data from 50 separate data sources; each with a completely different database design and structure. To make matters worse, our marketing people haven't actually negotiated with all the data providers yet, so I am designing without a real idea of the scope of the whole problem. However, based on the data I do have access to, it is a certainty that the Primary keys will not be compatible between the different data sources. Each data source will have several hundred thousand records. Data will be imported weekly.
So I need to convert the relationships of these tables to the primary/foreign key structure I have designed. Right now the only way I can think to do this is to import the tables into staging tables. Then send the data to the main tbale from the main table of the state I am processing. At this point, I would update the Staging table with the new ID field and use triggers on it to update the related staging tables. Then I would import their data to the appropriate places. I was thinking I would have to use a cursor to do this, but I just realized how I can write the update query to avoid that as I was writing this. See you've half solved my problem already.
My real question though is does this process make sense? Is there a better way to approach this?
Unfortunately, in this case I will be receiving data from 50 separate data sources; each with a completely different database design and structure. To make matters worse, our marketing people haven't actually negotiated with all the data providers yet, so I am designing without a real idea of the scope of the whole problem. However, based on the data I do have access to, it is a certainty that the Primary keys will not be compatible between the different data sources. Each data source will have several hundred thousand records. Data will be imported weekly.
So I need to convert the relationships of these tables to the primary/foreign key structure I have designed. Right now the only way I can think to do this is to import the tables into staging tables. Then send the data to the main tbale from the main table of the state I am processing. At this point, I would update the Staging table with the new ID field and use triggers on it to update the related staging tables. Then I would import their data to the appropriate places. I was thinking I would have to use a cursor to do this, but I just realized how I can write the update query to avoid that as I was writing this. See you've half solved my problem already.
My real question though is does this process make sense? Is there a better way to approach this?