Foreign Keys
Posted by: Catling (---.cable.ubr01.telf.blueyonder.co.uk)
Date: April 03, 2008 03:05PM

How do i create foreign keys in phpMyAdmin?

Any help would be much appreciated

Options: ReplyQuote
Re: Foreign Keys
Posted by: Catling (---.cable.ubr01.telf.blueyonder.co.uk)
Date: April 03, 2008 04:12PM

i think i figure it out.

But I keep getting this error:

SQL query:

ALTER TABLE `movie` ADD FOREIGN KEY ( `Director_ID` ) REFERENCES `moviedatabase`.`director` (

`Director_ID`
);



MySQL said:

#1452 - Cannot add or update a child row: a foreign key constraint fails (`moviedatabase/#sql-c00_48`, CONSTRAINT `#sql-c00_48_ibfk_1` FOREIGN KEY (`Director_ID`) REFERENCES `director` (`Director_ID`))


Can anyone tell me why this is?

Options: ReplyQuote
Re: Foreign Keys
Posted by: bhushan.l (---.ttml.co.in)
Date: July 21, 2015 09:20AM

I have same problem....

Options: ReplyQuote
Re: Foreign Keys
Posted by: Otomatic (Moderator)
Date: July 21, 2015 09:48AM

Hi,

This is your MySQL configuration.
Foreign keys do not work with the MyISAM engine.

Read MySQL documentation.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Foreign Keys
Posted by: RiggsFolly (---.as43234.net)
Date: July 21, 2015 09:58AM

Hi Catling and bhushan,

WAMPServer do not write or maintain MySQL they just deliver it as part of the WAMPServer collection of Apache/MySQL/PHP/phpMyAdmin etc.

If you need to learn how to use MySQL or phpMyAdmin, please see my signature for links to the relevant product websites.


However the first thing to check is :-

Quote

FROM THE MANUAL

When you add a foreign key constraint to a table using ALTER TABLE, remember to create the required indexes first.


---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.