0

Hi People.

Got a small issue, although its big for me........

I'm using phpmyadmin....

I have 2 tables....

My First table is 'user' which has 4 columns ( eventid, Name, Email, Address ) ( eventid is the primary key)

My Second table is 'trips' and it has 6 colums ( tripid, eventid, firsttrip, secondtrip, thirdtrip,fourthtrip ) (tripid is the primary key and eventid is the foreign key)

I made eventid as INDEX in the trips table.

Problem is while establishing relationships between theae 2 tables.

I clicked on the child table (trips) clicked on Relation View

And I get 2 dropdown lists

tripid is having these options....

     trips ---> tripid
     trips ---> eventid
     user ---> eventid

eventid is having these options....

     trips ---> tripid
     trips --->  eventid
     user ----> eventid

And then ON DELETE --> CASCADE ON UPDATE--> CASCADE

no matter what option i select I'm getting an error...

 Cannot add or update a child row: a foreign key constraint fails (`jauntyroads/trips`, CONSTRAINT `trips_ibfk_1` FOREIGN KEY (`eventid`) REFERENCES `trips` (`eventid`) ON DELETE CASCADE ON UPDATE CASCADE)

Any idea experts...??

Sorry for te lengthy post

Regards

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Note, that some hosting providers do not allow foreign key relation. Check with their support to make sure.

0

I've changed from MyISAM to InnoDB...InnoDB does support foreign key thing... I've referred several youtube videos but still I'm getting this error of .......Cannot add or update a child row: a foreign key constraint fails

0

jauntyroads/trips

If the above is your fk name, it may cause the error. Switch the dash for an underscore.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.