When in doubt,
RTFM.
I'd much rather trust the documentation than google for what somebody else may or may not have done right.
http://dev.mysql.com/doc/refman/5.5/...ate-table.html
Samples from that page:
Code:
| [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...) reference_definition
...
reference_definition:
REFERENCES tbl_name (index_col_name,...)
[MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
[ON DELETE reference_option]
[ON UPDATE reference_option]
reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION
...
Which means, for example, you can write:
Code:
....
CONSTRAINT FOREIGN KEY productid REFERENCES products(productid) ON DELETE CASCADE
...
but it also means you could write
Code:
....
FOREIGN KEY productid REFERENCES products(productid) ON DELETE CASCADE
...
or you could write
Code:
....
CONSTRAINT fk_img_prodid FOREIGN KEY productid REFERENCES products(productid) ON DELETE CASCADE
...
By giving the constraint a name, you could later remove or alter it by name. Not a likely thing to do with a foreign key, which is why I seldom bother, but it just gives you more options.
So...MUCH better to get the *FULL* documentation with all possible options rather than just what one person chose to use.