Should I use foreign keys every related tables or shouldn’t I?
If I should use, why?
Should I use foreign keys every related tables or shouldn’t I? If I should
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
“All related tables” is not always clear, so it’s not an obvious situation. There can be tables that have a common column but may never see each other.
It’s handy, however, to prevent errors that slip past your primary defenses and allow data to be entered that’s not easily traceable.
They don’t help make queries more efficient if you have the proper indexes in place, and a good application will filter input enough that they should never be needed. But mistakes happen, and they are a cheap line of defense.
If you’re just getting comfortable with designing databases, they aren’t something to spend a lot of time worrying about and refining in great detail, once you have the basic parent/child relationships in place.
Here’s some background–
What's wrong with foreign keys?