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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:02:08+00:00 2026-05-24T14:02:08+00:00

With the following tables CREATE TABLE `Play` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id`

  • 0

With the following tables

CREATE TABLE `Play` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `room_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_FEBB7184A76ED395` (`user_id`),
  KEY `IDX_FEBB718454177093` (`room_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `User` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL,
  `nickname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_2DA17977F85E0677` (`username`),
  UNIQUE KEY `UNIQ_2DA17977A188FE64` (`nickname`),
  UNIQUE KEY `UNIQ_2DA17977E7927C74` (`email`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

INSERT INTO `User` VALUES(1, 'user', 'nickname', 'user@user.de');

CREATE TABLE `Room` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

INSERT INTO `Room` VALUES(1);

ALTER TABLE `Play`
  ADD CONSTRAINT `play_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `User` (`id`),
  ADD CONSTRAINT `play_ibfk_2` FOREIGN KEY (`room_id`) REFERENCES `Room` (`id`);

And trying to run the following statement

INSERT INTO `Play` (`id` ,`user_id` ,`room_id`) VALUES (NULL ,  '1',  '1')

I get an error

#1452 - Cannot add or update a child row: a foreign key constraint fails
(`play`, CONSTRAINT `play_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `User` (`id`))

Both data sets, #1 of User and #1 of Room exist in the databse. How can this fail? I am quite familiar with SQL, but I have no idea what the error is in this case…

  • 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-24T14:02:10+00:00Added an answer on May 24, 2026 at 2:02 pm

    Fixed it. It was an issue that only comes up when using MySQL 5.5.9, InnoDB and Mac OS X 10.6

    See: MySQL Bug #60309

    I changed the .conf of MySQL to add this line:

    [mysqld]
    lower_case_table_names=1
    

    And it works now. Thanks for your help anyway.

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

Sidebar

Related Questions

Given the following tables: CREATE TABLE Employees ( first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50)
I have a database with the following tables: create table Categories ( Id int
I created the following tables: CREATE TABLE PILOTO_COPILOTO ( nip number, anos_experienciencia float) TABLESPACE
So I want to create a user (schema) and a tablespace for a project,
How do I map these existing tables to the classes below? I have the
Short Version Is there a way to force (or provide a hint to) Microsoft
I am currently working on an old ASP application with a SQL Server 2000
I am trying to understand how the CLR implements reference types and polymorphism. I
In PostgreSQL, what's the simplest way to enforce more than just existence on a
I am creating a database that is trying to access values from a foreign

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.