Hi there, I am having some issues between two tables and foreign keys. Here is the two tables I have setup.
| complaints |CREATE TABLE `complaints` ( `complaintID` int(11) NOT NULL auto_increment, `ticket_number` varchar(20) NOT NULL default '', `complainant_name` varchar(100) NOT NULL default '', `program` varchar(100) NOT NULL default '', `date_added` datetime NOT NULL default '0000-00-00 00:00:00', `date_received` date NOT NULL default '0000-00-00', `date_response_due` date NOT NULL default '0000-00-00', `date_response_sent` date NOT NULL default '0000-00-00', `breach_complaint` tinyint(1) NOT NULL default '0', `nuisance_complaint` tinyint(1) NOT NULL default '0', `complaint_typeID` int(11) NOT NULL default '0', `refererID` int(11) NOT NULL default '0', `centreID` tinyint(4) NOT NULL default '0', `divisionID` tinyint(4) NOT NULL default '0', `complaint_statusID` tinyint(4) NOT NULL default '0', `userID` int(11) NOT NULL default '0', PRIMARY KEY (`complaintID`), UNIQUE KEY `complaintID` (`complaintID`), FOREIGN KEY (`complaintID`) REFERENCES `complaint_threads` (`complaintID`) ON DELETE CASCADE ) TYPE=InnoDB | | complaint_threads | CREATE TABLE `complaint_threads` ( `threadID` int(11) NOT NULL auto_increment, `message` text NOT NULL, `complaintID` int(11) NOT NULL default '0', `date_added` datetime NOT NULL default '0000-00-00 00:00:00', `userID` int(11) NOT NULL default '0', `parent_threadID` int(11) NOT NULL default '0', PRIMARY KEY (`threadID`), KEY `complaintID` (`complaintID`) ) TYPE=InnoDB | The complaints table I want to join to the complaint_threads table using complaintID. I dont know if I have set this up right, but i'm getting foreign key constraint errors :\ How can i set this up properly, so when I delete an entry in complaints it will cascade delete in complaint_threads . Please let me know. Dan -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]