Possible Duplicate:
What’s wrong with foreign keys?
I use MS Sql Server with a large database about 4 GB data.
I search around the web why I should use foreign keys. by now I only indexed the keys used to join tables. Performance is all fine, dataintegrety is no problem.
Should I use foreign keys? Will I get even more performance with foreign keys?
Foreign key's don't actually improve performance, in fact they incur a small performance penalty on all write operations, to ensure that the constraint is followed.
The reason why you want to use these is to prevent destructive write operations. If you don't have them, buggy code, or a bad sql statement can remove rows that are expected to be there.
Integrity may not be a problem today, but that's the exact attitude that makes it a problem tomorrow or two weeks from now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With