Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Foreign Keys and Indexes

Status
Not open for further replies.

dstrange

Programmer
Nov 15, 2006
87
0
0
CA
Hi, I'm kinda new to this so please be patient. I'm using MySQL Query Browser to setup some Foreign Keys and Indexes but I keep getting the dreaded 1452 error.

What is the general rule of thumb for what should come first? Foreign Keys or Indexes?
Also is it bad practice to have the same columns for both indexes and foreign keys?

Thanks in advance.
 
the general rule is that your foreign key has to have an index

in version X (not sure which level, you could look it up in da manual), the index is "silently" created if you forget to declare it explicitly

no, it most certainly is not bad practice to have an index on a foreign key -- in fact, it is bad practice not to

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top