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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:42:21+00:00 2026-05-24T01:42:21+00:00

Hello I have two mysql tables one that holds username and password second that

  • 0

Hello I have two mysql tables one that holds username and password second that holds user information. Here are the tables:

CREATE  TABLE IF NOT EXISTS `test`.`dbo.users` (
  `userId` INT(11) NOT NULL AUTO_INCREMENT ,
  `userUsername` VARCHAR(45) NULL ,
  `userPassword` VARCHAR(45) NULL ,
  `dbo.userProfiles_userProfileId` INT(11) NOT NULL ,
  PRIMARY KEY (`userId`, `dbo.userProfiles_userProfileId`) ,
  INDEX `fk_dbo.users_dbo.userProfiles` (`dbo.userProfiles_userProfileId` ASC) ,
  CONSTRAINT `fk_dbo.users_dbo.userProfiles`
    FOREIGN KEY (`dbo.userProfiles_userProfileId` )
    REFERENCES `test`.`dbo.userProfiles` (`userId` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `test`.`dbo.userProfiles` (
  `userProfileId` INT(11) NOT NULL AUTO_INCREMENT ,
  `userId` INT(11) NOT NULL ,
  `userFirstName` VARCHAR(45) NULL ,
  `userMidleName` VARCHAR(45) NULL ,
  `userLastName` VARCHAR(45) NULL ,
  `userBirthDate` VARCHAR(45) NULL ,
  `userCountry` VARCHAR(45) NULL ,
  `userState` VARCHAR(45) NULL ,
  `userCity` VARCHAR(45) NULL ,
  `userZipCode` VARCHAR(45) NULL ,
  `userPrimaryAddress` VARCHAR(45) NULL ,
  `userSecondaryAddress` VARCHAR(45) NULL ,
  `userThirdAddress` VARCHAR(45) NULL ,
  `userFirstPhone` VARCHAR(45) NULL ,
  `userSecondaryPhone` VARCHAR(45) NULL ,
  `userThirdPhone` VARCHAR(45) NULL ,
  `userFirstEmail` VARCHAR(45) NULL ,
  `userSecondaryEmail` VARCHAR(45) NULL ,
  `userThirdEmail` VARCHAR(45) NULL ,
  `userDescription` VARCHAR(45) NULL ,
  PRIMARY KEY (`userProfileId`, `userId`) )
ENGINE = InnoDB;

My problem with this tables is that the fk key doesn’t work and I’m not sure why I’m missing something here.. ( I haven’t used foreign keys much).

Error:

Executing SQL script in server

ERROR: Error 1005: Can’t create table ‘test.dbo.users’ (errno: 150)

Can you please help fixing this so I can use fk on this tables and others? and if you got some time to spare to explain me how fk keys work exactly (using mysql workbench to create them on a diagram then forward engineer). thank you for your help

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

    You have to create the root tables first (userProfiles). You can temporarily bypass this restriction by disabling foreign key checks with set foreign_key_checks=0. This must be done if you’re creating multiple tables with circular references.

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

Sidebar

Related Questions

Hello I have two dependants select box, the second one is popularited after onchange
I have two arrays: $array1 = array(1=>1,10=>1,12=>0,13=>13); $array2 = array(1=>Hello,10=>Test,12=>check,13=>error); Here $array1 has keys
Hello I have problem to put together animations of two separate objects to second
I have two tables, Hello and World: Hello has two columns id(int) and id1(int,
Let's say I have two tables: TABLE A MessageID | Message 1 | Hello
I have two android applications. The apks are Hello.apk and Fonts.apk I would like
Let's say I have these two arrays: string[] arr1 = new string[2]{Hello, Stack} string[]
Hello I have two text inputs which get their values from a datepicker. What
Hello i have two columns: duration (int) and dateCol (date) in a table. How
Hello I have two project in a .NET 4.0 framework visual studio solution. First

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.