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

  • Home
  • SEARCH
  • 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 6834479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:07:00+00:00 2026-05-26T23:07:00+00:00

I’ve seen this problem loads of time on forums, but I can’t seem to

  • 0

I’ve seen this problem loads of time on forums, but I can’t seem to solve the issue for my particular situation.
I’m getting the following error on a simple insert.

Cannot add or update a child row: a foreign key constraint fails (`bag_track`.`job`, CONSTRAINT `fk_JOB_FLIGHT1` FOREIGN KEY (`FLIGHT_ID`) REFERENCES `FLIGHT` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION)

Here are my table definitions:
Flight table

CREATE  TABLE IF NOT EXISTS `BAG_TRACK`.`FLIGHT` (
 `ID` INT NOT NULL AUTO_INCREMENT ,
`FLIGHT_NUM` VARCHAR(15) NOT NULL ,
`ORIGIN` VARCHAR(45) NOT NULL ,
`ARRIVAL_TIME` DATETIME NOT NULL ,
`STATUS` VARCHAR(45) NOT NULL ,
`CAROUSEL_ID` INT NOT NULL ,
`GATE_ID` INT NOT NULL ,
`AIRCRAFT_TYPE_ID` INT NOT NULL ,
PRIMARY KEY (`ID`) ,
INDEX `fk_FLIGHT_CAROUSEL1` (`CAROUSEL_ID` ASC) ,
INDEX `fk_FLIGHT_GATE1` (`GATE_ID` ASC) ,
INDEX `fk_FLIGHT_AIRCRAFT_TYPE1` (`AIRCRAFT_TYPE_ID` ASC) ,
CONSTRAINT `fk_FLIGHT_CAROUSEL1`
FOREIGN KEY (`CAROUSEL_ID` )
REFERENCES `BAG_TRACK`.`CAROUSEL` (`ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_FLIGHT_GATE1`
FOREIGN KEY (`GATE_ID` )
REFERENCES `BAG_TRACK`.`GATE` (`ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_FLIGHT_AIRCRAFT_TYPE1`
FOREIGN KEY (`AIRCRAFT_TYPE_ID` )
REFERENCES `BAG_TRACK`.`AIRCRAFT_TYPE` (`ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8;

Job Table

    CREATE  TABLE IF NOT EXISTS `BAG_TRACK`.`JOB` (
  `ID` INT NOT NULL AUTO_INCREMENT ,
  `STATUS` VARCHAR(45) NOT NULL ,
  `LONGITUDE` FLOAT NULL ,
  `LATITUDE` FLOAT NULL ,
  `SPEED` VARCHAR(45) NULL ,
  `JOB_DATE` DATE NULL ,
  `START_TIME` TIME NULL ,
  `TOTAL_TIME` DOUBLE NULL ,
  `COMPLETION_DATE` DATE NULL ,
  `USER_ID` INT NOT NULL ,
  `ROUTE_ID` INT NOT NULL ,
  `FLIGHT_ID` INT NOT NULL ,
  PRIMARY KEY (`ID`, `FLIGHT_ID`) ,
  INDEX `fk_JOB_USER1` (`USER_ID` ASC) ,
  INDEX `fk_JOB_ROUTE1` (`ROUTE_ID` ASC) ,
  INDEX `fk_JOB_FLIGHT1` (`FLIGHT_ID` ASC) ,
  CONSTRAINT `fk_JOB_USER1`
    FOREIGN KEY (`USER_ID` )
    REFERENCES `BAG_TRACK`.`USER` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_JOB_ROUTE1`
    FOREIGN KEY (`ROUTE_ID` )
    REFERENCES `BAG_TRACK`.`ROUTE` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_JOB_FLIGHT1`
    FOREIGN KEY (`FLIGHT_ID` )
    REFERENCES `BAG_TRACK`.`FLIGHT` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

I’m trying this simple insert

 insert into job (status, USER_ID, ROUTE_ID, FLIGHT_ID) VALUES ('UNLOADING', 1, 1, 2)

and getting the error above.
I have data in my flight table with the primary key of 1.
I’ve examined everything on my DB for typos etc and I’m at a loss to see what the problem isI’d be very grateful is anyone can help.

Thanks

B

  • 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-05-26T23:07:01+00:00Added an answer on May 26, 2026 at 11:07 pm

    Both your tables must use innoDb engine as you can read from the official doc.

    Both tables must be InnoDB tables and they must not be TEMPORARY
    tables.

    For the Flight table you have ENGINE = MyISAM instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.