========================================= Some information on the resulting tables: ========================================= mysql> show indexes from components; +------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | components | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | +------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ 1 row in set (0.00 sec) mysql> show indexes from articles; +----------+------------+--------------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +----------+------------+--------------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ | articles | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | | articles | 1 | articles_fk_component_id | 1 | component_id | A | 0 | NULL | NULL | | BTREE | | +----------+------------+--------------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ 2 rows in set (0.00 sec) mysql> show indexes from articles_local; +----------------+------------+-------------------------------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +----------------+------------+-------------------------------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ | articles_local | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | | articles_local | 0 | u_name | 1 | name | A | 0 | NULL | NULL | | BTREE | | | articles_local | 0 | u_name | 2 | component_id | A | 0 | NULL | NULL | | BTREE | | | articles_local | 1 | articles_local_fk_article_id_component_id | 1 | component_id | A | 0 | NULL | NULL | | BTREE | | | articles_local | 1 | articles_local_fk_article_id_component_id | 2 | article_id | A | 0 | NULL | NULL | | BTREE | | +----------------+------------+-------------------------------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+ 5 rows in set (0.00 sec) mysql> mysql> show create table components; +------------+-----------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+-----------------------------------------------------------------------------------------------------------------------+ | components | CREATE TABLE `components` ( `id` smallint(6) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +------------+-----------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> show create table articles; +----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | articles | CREATE TABLE `articles` ( `id` bigint(20) NOT NULL auto_increment, `component_id` smallint(6) NOT NULL, PRIMARY KEY (`id`), KEY `articles_fk_component_id` (`component_id`), CONSTRAINT `articles_fk_component_id` FOREIGN KEY (`component_id`) REFERENCES `components` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> show create table articles_local; +----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | articles_local | CREATE TABLE `articles_local` ( `id` bigint(20) NOT NULL auto_increment, `article_id` bigint(20) NOT NULL, `component_id` smallint(6) NOT NULL, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `u_name` (`name`,`component_id`), KEY `articles_local_fk_article_id_component_id` (`component_id`,`article_id`), CONSTRAINT `articles_local_fk_article_id_component_id` FOREIGN KEY (`component_id`, `article_id`) REFERENCES `articles` (`component_id`, `id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql>