If you are using MySQL with the InnoDB Storage Engine, you know
and probably use FOREIGN KEYs. There are some who dislikes the
use of these, saying the are bad for performance, but I tend to
disagree, if the price of keeping my data consistent is a slight
performance degradation, then so be it.
Anyway, I was going to write about a couple of lesser known
FOREIGN KEY constraint attributes here. We all know what a
FOREIGN KEY constraint is, right? A reference from a column or
set of columns in one table to the PRIMARY KEY in another table?
Yes, this is correct, but it's not the whole truth, actually, a
FOREIGN KEY is a reference to a PRIMARY KEY or UNIQUE key in
another table. Being able to reference a UNIQUE constraint is
sometimes rather useful.
But before we go into that, lets look at a few subtle differences
between a PRIMARY KEY and a UNIQUE constraint. In RDBMS design
lingo, the UNIQUE constraing usually represents a …
Showing entries 1 to 1
Dec
18
2008
Showing entries 1 to 1