我有一个表,用于映射其他两个表的两个主键。我将这两个字段作为外键。映射表没有主键 当我尝试插入两个表中已有的 2 个值时,出现Cannot add or update a child row: aforeign key constraintfail错误。我该如何解决这个问题?
我的表是这样的:
CREATE TABLE IF NOT EXISTS fuse_package_component_members
( component_id int(11) NOT NULL,
member_type int(11) NOT NULL,
member_id int(11) NOT NULL,
active_date date NOT NULL,
inactive_date date NOT NULL,
KEY component_id (component_id),
KEY member_id (member_id) )
ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE fuse_package_component_members
ADD CONSTRAINT comp_id_fk
FOREIGN KEY (component_id) REFERENCES fuse_component_definition (component_id) ON UPDATE NO ACTION,
ADD CONSTRAINT ele_id_fk
FOREIGN KEY (member_id) REFERENCES fuse_product_element …Run Code Online (Sandbox Code Playgroud)