If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site. my story is that i do so much updates on the staging database, Faculty table, change lots of faculty comment and name without changing Class table.When I try to do an update on either table, I get a 'The UPDATE statement conflicted with the REFERENCE constraint..' which refers to the foreign key constraint.How can I update the language field on both of these tables?A FOREIGN KEY is a key used to link two tables together.A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in another table.Also, it is interesting to note that while this query works (Note the PRIMARY KEY line): CREATE TABLE `ffxi_character Job` ( `server ID` int(11) NOT NULL, `userid` int(10)unsigned NOT NULL, `character Name` varchar(255) NOT NULL, `job Abbr` char(4) NOT NULL, `job Level` int(11) default '0', PRIMARY KEY (`server ID`,`userid`,`character Name`,`job Abbr`), INDEX (`job Abbr`), CONSTRAINT FOREIGN KEY (`server ID`,`userid`,`character Name`) REFERENCES `ffxi_characters` (`server ID`,`userid`,`character Name`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT FOREIGN KEY (`job Abbr`) REFERENCES `ffxi_job Type` (`job Abbr`) ON DELETE CASCADE ON UPDATE CASCADE) TYPE=Inno DB; This query will give you an error 1005 and errno 150: CREATE TABLE `ffxi_character Job` ( `server ID` int(11) NOT NULL, `userid` int(10)unsigned NOT NULL, `character Name` varchar(255) NOT NULL, `job Abbr` char(4) NOT NULL, `job Level` int(11) default '0', PRIMARY KEY (`job Abbr`,`server ID`,`userid`,`character Name`), INDEX (`job Abbr`), CONSTRAINT FOREIGN KEY (`server ID`,`userid`,`character Name`) REFERENCES `ffxi_characters` (`server ID`,`userid`,`character Name`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT FOREIGN KEY (`job Abbr`) REFERENCES `ffxi_job Type` (`job Abbr`) ON DELETE CASCADE ON UPDATE CASCADE) TYPE=Inno DB; In order to make the second one work, you have to add: INDEX (`server ID`,`userid`,`character Name`)before the the foreign key is made.In a previous comment Dennis Haney provided an SQL snippet for finding rows that violate intended foreign key constraints.
|