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 4624768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:10:34+00:00 2026-05-22T03:10:34+00:00

I have a database with the following schema: The following SQL creates the relevant

  • 0

I have a database with the following schema:
enter image description here

The following SQL creates the relevant tables:

-- -----------------------------------------------------
-- Table `ninikske_bioldb`.`CodingRegion`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ninikske_bioldb`.`CodingRegion` (
  `CodRegID` VARCHAR(45) NOT NULL ,
      `CD_Start` INT NOT NULL ,
  `CD_Stop` INT NOT NULL ,
  `ORFs_ORF_ID` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`ORFs_ORF_ID`, `CodRegID`) ,
  INDEX `fk_Exons_ORFs1` (`ORFs_ORF_ID` ASC) ,
  CONSTRAINT `fk_Exons_ORFs1`
    FOREIGN KEY (`ORFs_ORF_ID` )
    REFERENCES `ninikske_bioldb`.`ORFs` (`ORF_ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `ninikske_bioldb`.`Experiment`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ninikske_bioldb`.`Experiment` (
  `Probe_GenomicPos` INT NOT NULL ,
  `SampleName` VARCHAR(45) NOT NULL ,
  `Intensities` FLOAT NOT NULL ,
  `ExperimentName` VARCHAR(45) NOT NULL ,
  `ProbeID` INT NOT NULL ,
  PRIMARY KEY (`Probe_GenomicPos`, `SampleName`, `ProbeID`) )
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ninikske_bioldb`.`CE`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ninikske_bioldb`.`CE` (
  `OrfId` VARCHAR(45) NOT NULL ,
  `CodRegId` VARCHAR(45) NOT NULL ,
  `GenPos` INT NOT NULL ,
  `ExpSam` VARCHAR(45) NOT NULL ,
  `ProbeId` INT NOT NULL ,
      PRIMARY KEY (`OrfId`, `CodRegId`, `GenPos`, `ExpSam`, `ProbeId`) ,
  INDEX `fk_CodingRegion_has_Experiment_Experiment1` (`GenPos` ASC, `ExpSam` ASC, `ProbeId` ASC) ,
  INDEX `fk_CodingRegion_has_Experiment_CodingRegion1` (`OrfId` ASC, `CodRegId` ASC) ,
  CONSTRAINT `fk_CodingRegion_has_Experiment_CodingRegion1`
    FOREIGN KEY (`OrfId` , `CodRegId` )
    REFERENCES `ninikske_bioldb`.`CodingRegion` (`ORFs_ORF_ID` , `CodRegID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_CodingRegion_has_Experiment_Experiment1`
    FOREIGN KEY (`GenPos` , `ExpSam` , `ProbeId` )
    REFERENCES `ninikske_bioldb`.`Experiment` (`Probe_GenomicPos` , `SampleName` , `ProbeID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

When I execute the following INSERT statement via Java:

String query = "INSERT INTO ninikske_bioldb.CE VALUES('" + cs.getORF_ID().getORF_ID() + "','" + cs.getCodRegID().getCodRegID() + "'," + cs.getExp().getProbePos() + ",'" + cs.getExp().getExpName()+ "', " + cs.getExp().getProbeID() + ");";
Statement stmt = con.createStatement();
stmt.executeUpdate(query);

I get the following error:

Cannot add or update a child row: a foreign key constraint fails (`ninikske_bioldb/CE`, CONSTRAINT `fk_CodingRegion_has_Experiment_Experiment1` FOREIGN KEY (`GenPos`, `ExpSam`, `ProbeId`) REFERENCES `Experiment` (`Probe_GenomicPos`, `SampleName`, `ProbeID`) )

I read several other questions about the same error message, but i can’t seem to find the insight I need.

Edit
The query is:
INSERT INTO ninikske_bioldb.CE VALUES('AT3G01190.1','cd474',67262,'H20', 1709);

When I check I the parent tables, I get following results:

mysql> SELECT * FROM CodingRegion WHERE ORFs_ORF_ID = 'AT3G01190.1';
+----------+----------+---------+-------------+
| CodRegID | CD_Start | CD_Stop | ORFs_ORF_ID |
+----------+----------+---------+-------------+
| cd474    |    67243 |   67649 | AT3G01190.1 | 
| cd475    |    67733 |   67892 | AT3G01190.1 | 
| cd476    |    67991 |   68176 | AT3G01190.1 | 
| cd477    |    68272 |   68484 | AT3G01190.1 | 
+----------+----------+---------+-------------+
4 rows in set (0.00 sec)

mysql> SELECT * FROM CodingRegion WHERE CodRegID = 'cd474';     
+----------+----------+---------+-------------+
| CodRegID | CD_Start | CD_Stop | ORFs_ORF_ID |
+----------+----------+---------+-------------+
| cd474    |    67243 |   67649 | AT3G01190.1 | 
+----------+----------+---------+-------------+
1 row in set (0.03 sec)

mysql> SELECT * FROM Experiment WHERE Probe_GenomicPos = '67262';
+------------------+--------------+-------------+----------------+---------+
| Probe_GenomicPos | SampleName   | Intensities | ExperimentName | ProbeID |
+------------------+--------------+-------------+----------------+---------+
|            67262 | 1signalpart1 |     8.94432 | H20            |    1709 | 
+------------------+--------------+-------------+----------------+---------+
1 row in set (0.00 sec)

mysql> SELECT * FROM Experiment WHERE SampleName = 'H20'
Empty set (0.00 sec)


mysql> SELECT * FROM Experiment WHERE ProbeID = '1709';           
+------------------+--------------+-------------+----------------+---------+
| Probe_GenomicPos | SampleName   | Intensities | ExperimentName | ProbeID |
+------------------+--------------+-------------+----------------+---------+
|            67262 | 1signalpart1 |     8.94432 | H20            |    1709 | 
+------------------+--------------+-------------+----------------+---------+
1 row in set (0.00 sec)

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-05-22T03:10:34+00:00Added an answer on May 22, 2026 at 3:10 am

    The constraint that’s failing, “fk_CodingRegion_has_Experiment_Experiment1”, requires that the values you enter for these three columns–GenPos, ExpSam, and ProbeId–already exist in the table “ninikske_bioldb.Experiment” in the columns Probe_GenomicPos, SampleName, and ProbeID. (In that order.)

    Look in the table ninikske_bioldb.Experiment for those three values.

    SELECT * 
    FROM ninikske_bioldb.Experiment
    WHERE Probe_GenomicPos = ?
      AND SampleName = '?'
      AND ProbeID = ?
    

    It’s possible that

    • the primary key of the table
      Experiment is wrong (should include
      ExperimentName rather than
      SampleName), or
    • the foreign key reference is wrong
      (should reference ExperimentName
      rather than SampleName), or
    • the function cs.getExp().getExpName()
      is the wrong function to use.

    I think the last one is the most likely. Probably should be getSampleName(), or something like that.

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

Sidebar

Related Questions

I have two tables with the following schema: CREATE TABLE sales_data ( sales_time date
I have no control over database schema and have the following (simplified) table structure:
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I have the following schema: Database: test. Table: per_login_user, Field: username (PK), password Database:
I have a table schema similar to the following (simplified): CREATE TABLE Transactions (
I have been using the following SQL to create a user, login and database.
I have a vessel tracking database schema with the following table for the schdual
I have the following mysql table schema: SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; -- -- Database: `network` --
I have a database where I store objects. I have the following (simplified) schema
I have a database schema that is similar to the following: | User |

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.