Friday 18 April 2008

Foreign Keys in Mysql

Here is a MYSQL statement to insert Foreign Keys:
create table table1(lid int(11) not null, tid mediumint(9), tag text, FOREIGN KEY(lid) REFERENCES table2(lid) ON DELETE CASCADE, FOREIGN KEY(tid) REFERENCES table3(tid) ON DELETE CASCADE, PRIMARY KEY(lid,tid));

No comments: