I have a task at hand of creating some kind of logic for a database. There is a IBM MQ Series setup in place today that replicates data from a couple of remote systems. At the moment it changes in the remote system and dumps the data into a staging table in a SQL Server 2005 database.
I want to validate the data according to some simple validation logic (required fields and data format) and some more advanced checks of the data hierarchy. The data being imported is hierarchical with a parent child relationship between some of the data. The hierarchical validation should check both data currently available in the staging table and the production table to make sure that there will be a valid hierarchy after the import completes.
If a validation of a record fails, the failure should be logged somehow and the failing records should not be imported, but the remaining records should. Records in the current production tables should be replaced by new records if they have the same id. The transfer of the data from the staging table should be made as soon as possible after that the data appears in the staging table.
As far as I know now, the total number of records in the production tables will not exceed 1 million and probable number of updated items per batch would be at the most a couple of thousand lines.
My question is what solution is best fit for importing the data?
I have thought of a couple of possible solutions:
Means of starting the transfer:
- Windows service that polls the staging table at a regular interval and kicks off some kind of transfer process whenever new data is inserted.
- Make the MQ kick off the transfer process upon inserting new data into the table
- Scheduling an SSIS job to run at a regular interval
Means of validating and transferring the data:
- Creating a SSIS job
- Creating Stored procedures
- Custom .NET code
My main concerns are that the hierarchy must remain intact in the production tables at all times and the data should be available in the production table shortly after appearing in the staging table. I cannot be sure that a full hierarchy is available at all times in the staging table.