i have to create two tables with a bidirectional relationship, as in the figure given below.

But it always gives an error. I am using the following query for creating the tables.
CREATE TABLE IF NOT EXISTS `rpt_operation` (
`op_id` int(45) NOT NULL,
`component` int(45) NOT NULL,
`ideal_time` time NOT NULL,
`handling_time` time NOT NULL,
PRIMARY KEY (`op_id`),
INDEX (component),
FOREIGN KEY (component)
REFERENCES rpt_component(comp_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `rpt_component` (
`comp_id` int(45) NOT NULL,
`lot_code` int(60) NOT NULL,
`lot_color` varchar(60) NOT NULL,
`drawing_num` int(60) NOT NULL,
`revision_num` int(60) NOT NULL,
`operation` int(45) NOT NULL,
PRIMARY KEY (`comp_id`),
INDEX (operation),
FOREIGN KEY (operation)
REFERENCES rpt_operation(op_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
The error appear in the line component int(45) NOT NULL of rpt_operation table.
Any help will be appreciated.
Thanks in advance
Your table structure is impossible. You can’t insert any records into
rpt_operationbecause there are no records inrpt_componentfor thecomponentforeign key, and you can’t insert any records intorpt_componentbecause there are no records inrpt_operationfor theoperationforeign key.If you make one or both of those fields nullable, then the table structure is still recursive, so you have to add one of the foreign keys manually, for example: