|
Hi, I have requirement of partitioning the two tables which have foreign key relationship between them. In some articles I read that table can't be partitioned if referenced by another table. My requirement is as below Tab1 and Tab2 needs to be partioned. Tab1 is referenced by Tab2. Can anyone tell me how can I partitioned both these tables. Thanks, Shailendra
(comments are locked)
|
|
It depends on what you want to accomplish with your partitioning. If you don't want "partition switching", you can use FK relations as long as you follow the rule below. Qoute from books online:
But if you plan to do fast "partition switching" you have some additional requirements regarding foreign keys:
As you can see, in this case, you can't use FK relations. reference : http://technet.microsoft.com/en-us/library/ms191160.aspx
(comments are locked)
|
|
Depending on how you partition them, you may end up dropping the unique constraint/primary key/unique index on Tab1 which allows Tab2 to reference it. If you drop that, then you will have to end up dropping the foreign key while you do it anyway. My advice to you would be to try to end up with a script which does the partitioning in a transaction before you roll it out to a production system - that way any failures will be backed out.
(comments are locked)
|
|
Hi Matt, Thanks for your advise. What do you mean by script which does the partitioning in a transaction? These tables have continuous bulky inserts; are you suggesting to write a script to remove releationship between them before each insert and recreate it once insert is done? Is there a better way to do it? Thanks, Shailendra Ha, I only just saw this. Basically, you can run DDL statements in a transaction just the same as DML statements. So you would need to begin a transaction, drop conflicting constraints, do the partitioning, re-create the constraints, commit the transaction.
Jan 13 '10 at 09:08 AM
Matt Whitfield ♦♦
(comments are locked)
|

