Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8517261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:38:57+00:00 2026-06-11T05:38:57+00:00

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

  • 0

i have to create two tables with a bidirectional relationship, as in the figure given below.
enter image description here
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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:38:58+00:00Added an answer on June 11, 2026 at 5:38 am

    Your table structure is impossible. You can’t insert any records into rpt_operation because there are no records in rpt_component for the component foreign key, and you can’t insert any records into rpt_component because there are no records in rpt_operation for the operation foreign 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:

    ALTER TABLE rpt_operation
      ADD CONSTRAINT
      FOREIGN KEY (component)
      REFERENCES rpt_component(comp_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using luasql. I have two tables of this type: IPINFO CREATE TABLE
I have to create a database with two tables in MySQL, but the script
I am getting an error when trying to create a relationship within two tables
I have the following two tables CREATE TABLE accounts ( id INTEGER UNSIGNED NOT
In my dbsql file, I have two CREATE TABLES the first works and the
I have two tables like, CREATE TABLE [dbo].[entry] ( [id] [int] NULL, [service] [int]
I have two tables: codes_tags and popular_tags. codes_tags CREATE TABLE `codes_tags` ( `code_id` int(11)
I have two tables: entitytype and project . Here are the create table statements:
I have two tables A and B as defined bellow. create table A (
So I have two tables structured like so: CREATE TABLE #nodes(node int NOT NULL);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.