DEV Community

Cover image for How and when to add foreign key constraints

How and when to add foreign key constraints

Kevin Coleman on April 14, 2019

Many rails projects rely on application validation to ensure data integrity. With rails presence validation, you can require associations exist in ...
Collapse
 
dmfay profile image
Dian Fay

Most databases don't automatically index foreign keys! MySQL's InnoDB engine does, but if you're using something else you'll have to evaluate whether to index the key column(s) yourself.

Collapse
 
kevincolemaninc profile image
Kevin Coleman

oo, I did not know that! I will update my post. Thank you!