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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:19:40+00:00 2026-05-14T04:19:40+00:00

I want to create a database in which there’s an n x m relationship

  • 0

I want to create a database in which there’s an n x m relationship between the table drug and the table article and an n x m relationship between the table target and the table article.

I get the error: Cannot delete or update a parent row: a foreign key constraint fails
What do I have to change in my code?

DROP TABLE IF EXISTS `textmine`.`article`;
CREATE TABLE  `textmine`.`article` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Pubmed ID',
  `abstract` blob NOT NULL,
  `authors` blob NOT NULL,
  `journal` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `textmine`.`drugs`;
CREATE TABLE  `textmine`.`drugs` (
  `id` int(10) unsigned NOT NULL COMMENT 'This ID is taken from the biosemantics dictionary',
  `primaryName` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `textmine`.`targets`;
CREATE TABLE  `textmine`.`targets` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `primaryName` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `textmine`.`containstarget`;
CREATE TABLE  `textmine`.`containstarget` (
  `targetid` int(10) unsigned NOT NULL,
  `articleid` int(10) unsigned NOT NULL,
  KEY `target` (`targetid`),
  KEY `article` (`articleid`),
  CONSTRAINT `article` FOREIGN KEY (`articleid`) REFERENCES `article` (`id`),
  CONSTRAINT `target` FOREIGN KEY (`targetid`) REFERENCES `targets` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `textmine`.`contiansdrug`;
CREATE TABLE  `textmine`.`contiansdrug` (
  `drugid` int(10) unsigned NOT NULL,
  `articleid` int(10) unsigned NOT NULL,
  KEY `drug` (`drugid`),
  KEY `article` (`articleid`),
  CONSTRAINT `article` FOREIGN KEY (`articleid`) REFERENCES `article` (`id`),
  CONSTRAINT `drug` FOREIGN KEY (`drugid`) REFERENCES `drugs` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • 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-14T04:19:40+00:00Added an answer on May 14, 2026 at 4:19 am

    I solved the problem by not declaring the Foreign Key inside of MySql but simply declaring them as ints.

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

Sidebar

Related Questions

I want to create a new row in my database on a table that
I have a table in my database which has duplicate records that I want
I want to create a SQL Server Express database on my local machine and
I want to create a trace on a database server from my C# app,
When I want to make a copy of a database, I always create a
I am reviewing / redesigning / refactoring a database and want to create a
In SQLite, given this database schema CREATE TABLE observations ( src TEXT, dest TEXT,
I want create a drop shadow around the canvas component in flex. Technically speaking
I want to create a Java application bundle for Mac without using Mac. According
I want to create a client side mail creator web page. I know the

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.