If two tables have foreign keys to the same primary key of another table, does that mean that two indexes are created for those foreign keys or do they use the same index (the primary key index?)
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.
Two indexes will be created; one for each foreign key (making for a total of three including the index on the primary key column). It should be noted that this is not true of other database systems which require you to explicitly add an index on a foreign key. MySQL’s innodb requires that an index be created when creating a foreign key relation.
See Foreign Keys for more.