On 14-11-17 01:42 AM, thufir wrote:
Looking at the docs:

http://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html

how do I alter the child table, links, so that it has a foreign key with
the parent table, feeds?

The workbench GUI came up with:

ALTER TABLE `rome_aggregator`.`links`
ADD INDEX `fk_links_1_idx` (`feed_id` ASC);
ALTER TABLE `rome_aggregator`.`links`
ADD CONSTRAINT `fk_links_1`
  FOREIGN KEY (`feed_id`)
  REFERENCES `rome_aggregator`.`feeds` (`id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE;

which would be a cascade, but otherwise seems correct. It's normal, or necessary, to have "ADD INDEX"?



-Thufir

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to