Foreign Key Versus Table Index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm slightly confused about foriegn keys and indexes on mysql innodb tables.
Foreign key constraints create a reference between two tables and indexes make queries on a particular table faster if the index is on a field in the where or order by clause.

My question was whether say for the following two tables:

Person                                 Car

Id                                       Id
Name                                 PersonId
Address                              Make
Phone Number                   Colour

If I create a foriegn key linking the id field in person and the personid field in car, do I need to create another index in car table specifically for the personid field if I was running a query such as:

"SELECT Id FROM car WHERE personid={personkeynumber}"?

Thanks for your help.

Jemma

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux