Foreign key

1) Add foreign key article_id ALTER TABLE article_log ________ REFERENCES article (id);

2) Remove foreign key ALTER TABLE article_log ______________;

3) View article_log foreign keys

Foreign keys helps prevent admin input errors, producing a more accurate database. Using constraint any attempt to link to a record which does not already exist will fail. Add foreign key ALTER TABLE article_log ADD FOREIGN KEY (article_id) REFERENCES article (id) ON DELETE CASCADE; Modify foreign key SHOW CREATE TABLE catg_path; CREATE TABLE `catg_path` ( `ancestor` int(10) unsigned NOT NULL, `descendant` int(10) unsigned NOT NULL, PRIMARY KEY (`ancestor`,`descendant`), KEY `descendant` (`descendant`), CONSTRAINT `catg_path_ibfk_1` FOREIGN KEY (`ancestor`) REFERENCES `catg` (`id`), CONSTRAINT `catg_path_ibfk_2` FOREIGN KEY (`descendant`) REFERENCES `catg` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ; ALTER TABLE catg_path DROP FOREIGN KEY catg_path_ibfk_1; ALTER TABLE catg_path ADD FOREIGN KEY (ancestor) REFERENCES catg (id) ON DELETE CASCADE;