# http://dev.mysql.com/doc/refman/5.1/ja/innodb-foreign-key-constraints.html [CONSTRAINT symbol] FOREIGN KEY [id] (index_col_name, ...) REFERENCES tbl_name (index_col_name, ...) [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}] [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}] MySQLはInnoDBじゃないと外部キー動かないだす 外部キーはunquie制約ついてないと駄目 drop database if exists hoge; create database hoge; use hoge