...

View Full Version : phpMyadmin Questions



teedoff
01-11-2012, 05:21 PM
Hi, I haven't dealt with creating tables in a long time, and even though this will be a coldfusion query on a MySQL database, I am in the middle of learning PHP so I thought I'd spend time learning how to admin databases using phpMyadmin.

I will say I also use Navicat as well. My problem is I'm working on a database for car lamp applications. So as of now I have 2 tables: carMaker and carMake. carMake is different models of a manufacture brand, so for instance Camaro, Chevelle, Belair all are Chevrolets. Falcon, Fairlane, Taurus all Fords.

I'll just show my table structures before describing my issue.

modelID model makerID
1 Camaro 2
2 Chevelle 2
3 Falcon 4
4 Fairlane 4
5 Challenger 5

This was created in Navicat. When I try to insert records using phpmyadmin, I get an error:


INSERTINTO`rlbulbs`.`carmake` (

`modelID` ,
`model` ,
`makerID`
)
VALUES (
'','Firebird','8'
)

MySQL said:
#1452 - Cannot add or update a child row: a foreign key constraint fails (`rlbulbs`.`carmake`, CONSTRAINT `carmake_ibfk_1` FOREIGN KEY (`modelID`) REFERENCES `carmaker` (`makerID`) ON UPDATE NO ACTION)


Again, please excuse my newbness with databases, in particular with phpmyadmin, but any tips and help would be greatly appreciated.

fatecaresx13
01-12-2012, 07:43 AM
Hmm well it looks like you have a foreign key constraint. That is you're referencing a value that doesn't exist in its reference table.

Example:

hosts:

host_id
host_name

uptime:

host_id
uptime_value

If I insert a host_id into the uptime table and the host_id doesn't exist in the hosts table and a foreign key contraint exists I'll get that error you're getting.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum