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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:30:37+00:00 2026-05-31T07:30:37+00:00

I’m working on a project that worksa with java and MySQL. My question is

  • 0

I’m working on a project that worksa with java and MySQL.
My question is about the MySQL part.

I’m working on a database and i’m trying to test everything but i can’t implementate any data.

I get all the time an error:
Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails(poker.inschrijving.CONSTRAIN inschrijving_ibfk_1 FOREIGN KEY(Lid)REFERENCES toernooi(Tid) ON DELETE CASCADE ON UPDATE CASCADE)

This is my Database:

CREATE DATABASE IF NOT EXISTS poker;
USE poker;

DROP TABLE IF EXISTS Locatie;
CREATE TABLE Locatie (
Lid int(12) NOT NULL AUTO_INCREMENT,
Lnaam Varchar(100) NOT NULL,
Ladress varchar(100) NOT NULL,
Lopp double,
PRIMARY KEY (Lid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `Locatie` (`Lid`,`Lnaam`,`Ladress`,`Lopp`) VALUES 
(10000001,'Grote zaal Den Bos','Lange weg 34, Den Bos',54.5),
(10000002,'Casino Vlaardingen','Achterbaan 119, Vlaardingen',2500.5),
(10000003,'Homerson Casino','Oxfordstraat 19, Zoetermeer',1000),
(10000004,'Van der valk casino','Dorpsweg 45, Sasseheim',9899);

DROP TABLE IF EXISTS Speler;
CREATE TABLE Speler (
Sid int(12) NOT NULL AUTO_INCREMENT,
Snaam varchar(50) NOT NULL,
Se_mail varchar(80) NOT NULL,
Sadress varchar(40) NOT NULL,
Swoonplaats varchar(35) NOT NULL,
Spostcode varchar(6) NOT NULL,
Stelnr int(19) NOT NULL,
Sgesl ENUM('M', 'F'),
Sgbd date NOT NULL,
Srating int(10) NOT NULL,
Sgewonnen_geld double NOT NULL,
Sbekende_speler boolean,
PRIMARY KEY (Sid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `Speler` (`Sid`,`Snaam`,`Se_mail`,`Sadress`,`Swoonplaats`,`Spostcode`,`Stelnr`,`Sgesl`,`Sgbd`,`Srating`,`Sgewonnen_geld`,`Sbekende_speler`) VALUES 
(20000003,'Jan Peter','Jpeter@gmail.com','Scherium weg 20','Den bos','2123IE',062586475,'M','1983-05-18',1250,209.00,False),
(20000001,'Roy Henson','Roy.Henson@telfort.nl','Shindori straat 231','Leiden','3212IO',0623568974,'M','1986-08-21',700,2310.00,True),
(20000009,'Willium Ransom','WilRan@hotmail.com','Hooftweg 521','Groningen','1251UI',0623541289,'M','1979-04-29',1250,20315.00,True),
(20000002,'Rhindia Rosenberg','RhindiaR@gmail.com','Dorpstraat 210','Den Haag','2621',0622775412,'F','1990-11-21',275,10321.00,False);

DROP TABLE IF EXISTS Toernooi;
CREATE TABLE Toernooi (
Tid int(12) NOT NULL AUTO_INCREMENT,
Tnaam varchar(100) NOT NULL,
Tmax_speler int(5) NOT NULL,
Tinleggeld double NOT NULL,
Ttype varchar(25) NOT NULL,
Tdatum datetime NOT NULL,
Lid int(12) NOT NULL,
PRIMARY KEY (Tid),
FOREIGN KEY (Lid) REFERENCES Locatie (Lid)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `Toernooi` (`Tid`,`Tnaam`,`Tmax_speler`,`Tinleggeld`,`Ttype`,`Tdatum`,`Lid`) VALUES 
(30000001,'MCi',340,75.00,'Professional','2012-06-21 19:00:00',10000002),
(30000002,'chaos',200,150.00,'Professional','2012-07-15 21:00:00',10000003),
(30000003,'Homerson!',400,45,'Amatuer','2012-08-25 20:30:00',10000001),
(30000004,'Valkerin',1000,20,'Amatuer','2012-09-01 23:59:59',10000004);

DROP TABLE IF EXISTS MasterClass;
CREATE TABLE MasterClass (
Mid int(12) NOT NULL AUTO_INCREMENT,
Mmin_rating int(10) NOT NULL,
Mmax_spelers int(3) NOT NULL,
Mniveau varchar(50) NOT NULL,
Mdatum datetime NOT NULL,
Sid int(12) NOT NULL,
Lid int(12) NOT NULL,
PRIMARY KEY  (mid),
FOREIGN KEY (Lid) REFERENCES Locatie (Lid)
ON DELETE RESTRICT
ON UPDATE CASCADE,
FOREIGN KEY (Sid) REFERENCES Speler (Sid)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `MasterClass` (`Mid`,`Mmin_rating`,`Mmax_spelers`,`Mniveau`,`Mdatum`,`Sid`,`Lid`) VALUES 
(40000001,1100,50,'Professional','2012-05-21 22:00:00',20000009,10000001),
(40000002,3500,120,'Amateur','2012-09-07 15:00:00',20000001,10000002);

DROP TABLE IF EXISTS Status;
CREATE TABLE Status (
Tid int(12) NOT NULL,
Sid int(12) NOT NULL,
ronde varchar(25) NOT NULL,
tafel int(3) NOT NULL,
winst double NOT NULL,
startrating int(10) NOT NULL,
eindrating int(10) NOT NULL,
plaats int(5) NULL,
PRIMARY KEY (Tid,Sid),
FOREIGN KEY (Tid) REFERENCES Toernooi (Tid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (Sid) REFERENCES Speler (Sid)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `Status` (`Tid`,`Sid`,`ronde`,`tafel`,`winst`,`startrating`,`eindrating`)    VALUES 
(30000004,20000003,20,5,0.00,800,700),
(30000004,20000001,12,2,0.00,750,600),
(30000004,20000002,4,19,6700.00,1000,1250),
(30000004,20000009,9,12,3400.00,250,275);

DROP TABLE IF EXISTS Inschrijving;
CREATE TABLE Inschrijving (
Iid int(12) NOT NULL,
Sid int(12) NOT NULL,
Ibetaald boolean,
PRIMARY KEY  (Iid,Sid),
FOREIGN KEY (Iid) REFERENCES Toernooi (Tid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (Iid) REFERENCES MasterClass (Mid)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY (Sid) REFERENCES Speler (Sid)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `Inschrijving` (`Iid`,`Sid`,`Ibetaald`) VALUES 
(40000001,20000003,true), //Its goes wrong here!!! This is where the error come
(40000002,20000002,false),
(30000003,20000001,true),
(30000004,20000009,false);

I hope someone can help me!
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-31T07:30:39+00:00Added an answer on May 31, 2026 at 7:30 am

    You have an interesting foreign key structure: the Iid points to two tables at the same time. When you add a new Inschrijving.Iint, there must be rows with the same Iid values in both referenced tables!

    CREATE TABLE Inschrijving (
    Iid int(12) NOT NULL,
    !!
    FOREIGN KEY (Iid) REFERENCES Toernooi    (Tid) ON DELETE CASCADE ON UPDATE CASCADE,
    FOREIGN KEY (Iid) REFERENCES MasterClass (Mid) ON DELETE CASCADE ON UPDATE CASCADE,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.