On Wed, 2005-08-24 at 06:11 -0500, John Gonzales wrote:
> CREATE TABLE `journal` (
>   `journal_id` int(10) unsigned NOT NULL auto_increment,
>   `journal_category` int(10) unsigned NOT NULL default '1',
>   `journal_datetime_created` timestamp NOT NULL default CURRENT_TIMESTAMP,
>   `journal_datetime_modified` timestamp NOT NULL default '0000-00-00
> 00:00:00',
>   `journal_title` varchar(50) NOT NULL default 'no title',
>   `journal_entry` blob NOT NULL,
>   PRIMARY KEY  (`journal_category`),
>   KEY `journal_category` (`journal_id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1
>  
> [jg.] 
> CREATE TABLE comments
> (
>   comment_id INT,
>   comment_journal_id INT,
>   INDEX  jrn_id (journal_id),
>   FOREIGN KEY (comment_journal_id) REFERENCES journal (journal_id)
>   ON DELETE CASCADE ON UPDATE CASCADE
> ) TYPE = INNODB;
> 
> I got this as a respsone:
> Key column 'journal_id' doesn't exist in table

From the manual:
http://dev.mysql.com/doc/mysql/en/innodb-foreign-key-constraints.html

"Corresponding columns in the foreign key and the referenced key must
have similar internal data types inside InnoDB so that they can be
compared without a type conversion. The size and the signedness of
integer types has to be the same."

You've got an INT in comments table and an int(10) unsigned in the
journal table. They need to match in signedness.
-- 
Pat Adams
Applications Programmer
SYSCO Food Services of Dallas

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to