Reputation: 15419
There is a lot of (older) related data spread over many tables in our database that needs archiving to a separate database then deleting from the original database (probably daily). What is archived (and deleted) is determined by business rules. We don't want newer data in this archive (it changes and is accessed frequently). Some of the archived data may need transferring back if required and possibly reported on.
I need to come up with an efficient and easy to maintain solution in SSIS. I can think of at least three ways of doing this:
I considered staging tables, though I don't see a benefit in this case - I can copy the data directly to the archive table with a timestamp (timestamp = process started) then when finished, go and delete the id's that were timestamped at the time the process started. Once I've identified the job id, I know the rest of the data that needs to be archived too.
I'm looking for the optimal approach, does anyone have another approach? How would other people achieve this?
Upvotes: 2
Views: 4087
Reputation: 716
Use CQRS. The problem is in the term "related data". If you segregate your reads (all possible reads in own database/tables) you will not have a need for related data and can apply rules to each "Aggregate" separately if necessary. Let's say for list views you an get count from two different sources (actual and archived data) when you are rendering pager. For detail view you still can have UUID's for each resource but in this case application will read from different data stores. The key point here is you get rid of all kind of joins.
Upvotes: 0
Reputation: 40359
Sounds like you need two processes, one to archive old data, and one to reload archived data. I’d tackle both with the following methodology.
For Archiving data:
For Reloading data, it’d be pretty much the same process, but working from the archive set to the “live” set. Special considerations would include:
This methodology would work regardless of tool—SSIS or otherwise.
Upvotes: 6
Reputation: 56
Could you please be more specific?
Do you need the 'old' data still present in your current database? If yes - then you can simply:
If you don't need the 'old' data in the existing database, inserting the required archive data to new database will be the way to go. Depending what you need in the archive database - if you don't need the non-key you can go for normalization otherwise table by table approach will be good.
if this helps please mark as answer
Upvotes: 0