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 have a table in my database for which I want to create a
I need some advice regarding which database I should use. I want to create
I want to create dynamic number of thread which is depends on the database
I have a table in my database which has duplicate records that I want
I want to create a MySQL database which should contain all the users of
I want to create a SQLite database in my app, which contains three tables,
I have a table in a MySQL Database which has this structure: CREATE TABLE
Ok, so I want to create a database with all the data of the
I use Entity Framework code-first. DataBaseName - I want to create a database in
I want to create a 'mini-database'. I want to have one file with lots

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.