Let's say I have a customer parent table and an orders child table. I set createconstraints to true for the datarelation, and I also add foreignkeyconstraints for delete and update to cascade. All works as expected. Now let's say the number of customer records gets so large I have to load only subsets of the customer records into the dataset. However, the number of order records is still manageable, so I continue to load them all in. When adding the datarelation if an order exists and I didn't happen to load in the parent customer record I get an error. So I try to set the createconstraints of the datarelation to false. Now the datarelation will load, but I get an error when trying to add a foreignkeyconstraint.
Since I will work only with the customer records that are currently loaded in the dataset, and essentially ignore any order records whose parent customer record is not present, how can I do this and still have the benefit of the foreignkeyconstraint cascading my deletes and updates? I guess I could only load the order records whose parent is present, but I was looking for an easier way. Thanks for any advice.
Asked
Active
Viewed 216 times
0

Ron V
- 11
- 4
-
You can't have it both ways. Either your foreign key is enforced or its not. – jmcilhinney Oct 27 '16 at 21:52
-
the only thing you can do is, when customer requested - load only orders for this customer. If Order requested - load only customer for this order – T.S. Oct 27 '16 at 23:24
-
Thanks, Jmcilhinney and T.S. that's what I thought... – Ron V Oct 28 '16 at 12:19