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);
In general, an "index" is used for performance, while a "constraint" is
used for logical concepts, like uniqueness. Most often, the DBMS uses
an index to implement these logical concepts, but it's better to understand
the difference.
A foreign key needs a unique constraint (either a primary of a secondary
unique constraint) to "point to": when there's no uniqueness in the parent
table, it cannot point to a record in that table.
With regards,
Martijn Tonies
Upscene Productions
http://www.upscene.com
Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql