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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:22:12+00:00 2026-05-28T01:22:12+00:00

I wonder whether someone can help me please. I have the following three tables:

  • 0

I wonder whether someone can help me please.

I have the following three tables:

Parent Table

CREATE TABLE `userdetails` (
  `userid` int(6) NOT NULL auto_increment,
  `forename` varchar(20) NOT NULL,
  `surname` varchar(30) NOT NULL,
  `emailaddress` varchar(150) NOT NULL,
  `password` varchar(200) NOT NULL,
  `passwordhint` varchar(20) NOT NULL,
  `subscriptionexpiration` date NOT NULL,
  `salt` varchar(200) NOT NULL,
  PRIMARY KEY  (`userid`),
  UNIQUE KEY `emailaddress` (`emailaddress`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Child Table

CREATE TABLE `detectinglocations` (
  `userid` int(6) NOT NULL,
  `locationid` int(6) NOT NULL auto_increment,
  `locationname` varchar(80) NOT NULL,
  `address` varchar(110) NOT NULL,
  `osgb36lat` float(10,6) NOT NULL,
  `osgb36lon` float(10,6) NOT NULL,
  `osgridref` varchar(20) NOT NULL,
  `wgs84latd` int(2) NOT NULL,
  `wgs84latm` int(2) NOT NULL,
  `wgs84lats` decimal(6,2) NOT NULL,
  `wgs84latb` varchar(1) NOT NULL,
  `wgs84lond` int(2) NOT NULL,
  `wgs84lonm` int(2) NOT NULL,
  `wgs84lons` decimal(6,2) NOT NULL,
  `wgs84lonb` varchar(1) NOT NULL,
  `nameoflocationcontact` varchar(30) NOT NULL,
  `locationcontactsaddressline1` varchar(50) NOT NULL,
  `locationcontactsaddressline2` varchar(50) default NULL,
  `locationcontactsaddressline3` varchar(50) default NULL,
  `locationcontactsaddressline4` varchar(50) default NULL,
  `locationcontactstelephonenumber` varchar(15) default NULL,
  PRIMARY KEY  (`locationid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Child Table

CREATE TABLE `detectors` (
  `userid` int(6) NOT NULL,
  `detectorid` int(6) NOT NULL auto_increment,
  `detectorname` varchar(30) NOT NULL,
  PRIMARY KEY  (`detectorid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=0 AUTO_INCREMENT=1 ;

Using the this code below, I’m trying to implement the ‘Delete Cascade’ functionality, whereby if the user is deleted from the parent table, the associated rows within the child tables are alse deleted.

ALTER TABLE 'tablename'
   add CONSTRAINT fk_userdetails
   FOREIGN KEY (userid)
   REFERENCES userdetails(userid)
   ON DELETE CASCADE

I can successfully implement this for the first child table, but when I try to do the same with the second child table I receive the following error:

#1005 - Can't create table './db369054642/#sql-30d_bd1a57.frm' (errno: 121) 

I’ve done quite a bit of research to find out what the problem may be, but I must admit I’m none the wiser.

Could someone perhaps have a look at this please and let me know what I’m doing wrong?

Many thanks

  • 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-28T01:22:13+00:00Added an answer on May 28, 2026 at 1:22 am

    The solution is on http://dev.mysql.com/doc/refman/5.0/en/innodb-error-codes.html in the post by Mark Robbins on September 29 2007 10:19pm and the next one:

    • Constraint names must be unique
    • fk_userdetails is not unique

    So you might try

    ALTER TABLE 'tablename'
       add CONSTRAINT fk_userdetails_detectors
       FOREIGN KEY (userid)
       REFERENCES userdetails(userid)
       ON DELETE CASCADE
    

    on the second table

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

Sidebar

Related Questions

I wonder whether someone can help me please. I have the following xml file
I wonder whether someone can help me please. I'm using the following script to
wonder whether someone can help me with the following one... I have a struct
I wonder whether someone can help me please. I have a mySQL database which
I wonder whether someone can help me please. I'm using the following script to
I wonder whether someone can help me please. I've put together the following which
I wonder whether someone can help me please. I'm trying to put together a
I wonder whether someone can help me please. I'm trying to put together a
I wonder whether someone can help me please. I've put together this page, which
I wonder whether someone can help me please. I've put together the script below

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.