Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 ForeignKey structure with archive tables

Author  Topic 

Mopani
Yak Posting Veteran

55 Posts

Posted - 2009-06-25 : 02:05:32
I have 4 main tables.. that need to be archived once a week, in order to preserve historical data at given dates. So I have the following relationships set.
Table1.AcctID = Primary Key
Table2.AcctID = ForeignKey referencing Table1.AcctID
Table3.AcctID = ForeignKey referencing Table1.AcctID
Table4.AcctID = ForeignKey referencing Table1.AcctID

Should AcctID in tables 2,3&4 also be primary keys?

The archived versions of these tables will be ...

Arch_Table1.AcctID
Arch_Table2.AcctID
Arch_Table3.AcctID
Arch_Table4.AcctID

Do these tables have a ForeignKey structure amongst themselves pointing to Arch_Table1.AcctID (similar to the first bunch of tables) ?
... or should all these archive tables reference Table1.AcctID

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-06-25 : 11:53:55
you will need to point it to where ever the data is. You could just move all the tables into another database and retain the naming conventions for the tables, indexes, FKs etc. When you need the data you can just bring them back into your current DB. This is a whole lot of less hassle than moving the data to another table, renaming & recreating the indexes, FKs etc ...

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -